I have two series that overlay pretty close in time but not exactly. So I need to plot each series with the corresponding time component to get the match. Also the number of points is different, by a factor of 10.
How to plot two scatter-plots on the same plot using the time domain as the x-axis? eg
t1: 0.1 0.3 0.5 ...
y1: 3 7 9 ...
t2: 0.18 0.21 0.34 0.41 0.56 ...
y2: 32 55 4 7 1 ...
As you can see I can't just highlight all because the series don't match up so well in time.
If output something like this is what you want:
then it may be simplest to plot one series (say y1), select the Plot Area, Select Data... and add your second (y2) series.
It's also pretty easy to make the chart using the first range, then copy the X and Y values for the second series (hopefully it's in adjacent columns, but you can use Ctrl+Select to select multiple areas). Then select the chart, and use Paste Special to add the copied data as a new series, in columns, X values in first column.
Related
I want to subtract all rows of a file from its first row, and then plot it. How can I implement such math work in gnuplot?
Here is an example of what i want to do:
Let's say i have a file that has two columns and 1000 rows. I want a script that subtract all data's in 2nd column from the 2nd column value in first row.
I am pretty sure that there are a similar questions on SO, however, apparently not so easy to find.
I would have searched for "normalization" or "offset".
The following example works even if you have single or double empty lines in your data. The expression in the plot command uses serial evaluation, check help operators binary.
Sometimes, you might see similar solutions using the pseudocolumn 0 (check help pseudocolumns), however, which might lead to wrong results if you have empty lines in your data.
Script:
### offset data: subtraction of first value in a column
reset session
$Data <<EOD
0 10
1 11
2 12
3 13
4 14
5 15
6 16
7 17
EOD
plot t=0 $Data u 1:(t==0?y0=$2:0,t=t+1,$2-y0) w lp pt 7 lc "red"
### end of script
Result:
How frustrating is Excel.. working on this for half an hour now.
I simply try to make a frequency plot of two groups, with different colours. On the x-axis I would like to display the subject.ids per bar.
However, if I select a different range for the horizontal x axis per series (series 1 = blue, series 2 = orange) with the subject id, it changes the x-axis in the other series to the same. What in hell am i doing wrong?
3007 1
23121 1
3009 1
3005 1
3011 2
23171 2
3207 2
3102 3
3207 6
13302 7
2411 11
23191 11
3008 11
3106 12
110031 1
110031 1
110030 1
110017 1
110014 1
110008 1
110004 1
110007 2
110035 4
110020 4
110003 4
110036 10
110019 11
110015 21
AFAIK, you cannot put 2 series onto the x axis.
You have 2 alternate ways to solve your problem:
Concatenate each positional pair into a new column and use this as the x-axis label series. It will look like this:
You could use data labels for each series. However, this will add the data to the columns themselves and not the axis (you could put it at the base of the column). To do so, you will need to right click on the graph, select 'Add Data Labels'. By default it adds the value as the label, but you can select the labels, right click to format the data labels and use the 'values from cells' option. Once you do this and play around with the orientation and location of the labels, it will look like this:
For simplicity, I'd go with the first method
Adding a 3rd option; simply put the columns for the axis labels beside each other and when selecting the Data for the Axis Labels, just select both columns instead of the usual 1. It will look like this:
I am trying to create a graph where:
X1 5 10 15 20
X2 10 20 25 30
Y 0 1 1 0
X1 is a minimum value of something, X2 the maximum, and Y the binary outcome--was my event true or not. In my head I picture it as a scatter plot where the horizontal axis is my min, the vertical my max, and there is a color coded dot that shows whether the event is true or not. I can't seem to create this.
I am not aware of a way to do this directly in Excel. As a workaround, you could sort your data by column Y. Then make a scatter plot of the the data where Y=0. Then you manually add the data where Y=1 as a second "series", i.e. right click the chart and click on Select Data, then on Add (Excel 2007).
I am doing a project that requires me to study the several condition that affect GPS accuracy, and after I collected a set of data and dumped it to Excel, I was trying to plot a scatter graph, grouping the data into different series according to a value: in this case, I wanted to plot the Latitude and Longitude values as the XY scatter values, and separate the series by the number of satellites when the fix was obtained.
Timestamp Latitude Longitude #Satellites
133009.279 3839.3354 904.7395 0
133010.279 3839.3354 904.7395 0
133011.279 3839.3354 904.7395 0
133026 3845.9863 907.4513 4
133027 3845.986 907.4491 4
133028 3845.9851 907.448 4
133222 3845.9909 907.4866 4
133023.28 3845.9817 907.4429 5
133024.28 3845.9867 907.4549 5
133048 3845.9868 907.452 5
133205 3845.9929 907.4858 5
133206 3845.9927 907.486 5
133207 3845.9925 907.4862 5
133056 3845.9885 907.4569 6
133057 3845.9881 907.4578 6
133223 3845.9905 907.4868 6
133224 3845.9901 907.487 6
I have tried selecting the three rows, adding the series afterwards by selecting the appropriate row, and even tried pivot tables, but these don't allow for scatter-plots unfortunately.
All this to no avail, but I am positive that you can plot the graph. Does anyone have an idea?
PS: Manually selecting the series myself isn't an option, since there is a large number of data. If I could select all of the data for one specific value in a row, though, would let my select each series, and I think I would be able to make it from there.
Have a look at the XY charts from FusionCharts XT - http://www.fusioncharts.com/demos/gallery/#bubble-and-xycharts
I am trying to write a script wrapping gnuplot that will take a dataset and produce an overlayed graph, the number of series to be plotted based on the number of distinct values in a given column, or based on the number of different datasets in the file. An example file would be:
#SeriesName x y
Series1 0 10
Series1 1 11
Series1 2 13
...
SeriesN 0 14
SeriesN 1 19
SeriesN 2 15
I have this in one continuous set of lines, but I can split it into index-able chunks if necessary. The problem is that I don't know the different names of the SeriesName values I'll have ahead of time, nor how many of distinct values there will be. But I want one line on the graph per distinct value of SeriesName. I can see how to make graphs if I know ahead of time the different values of SeriesName, but I don't know how to tell gnuplot to "make one line per value of series, and label each line with the name that is the value of SeriesName that was used for each line."
Can gnuplot do this? Otherwise, I can make two passes through the data, the first one of which I will gather the unique values of SeriesName, and then use bash/perl/python to explicitly build a `plot' statement, but it seems like gnuplot should have some functionality for a user to have to avoid that. Am I missing something?
Thanks in advance.
Update: I also posted to a forum to where the author of Gnuplot in Action (Philipp Janert) posts, and I posted a workaround to my own problem, but I don't think it qualifies as an answer, as what it ultimately does is make a second run through the data and then does a source code filter on gnuplot commands to make a gnuplot script compliant with a particular dataset. I would think that there would be an answer using just the syntax of gnuplot better than what I did. For reference, here is the link: http://www.manning-sandbox.com/thread.jspa?messageID=122752#122752
Just for the records, here is a solution which works with gnuplot>=4.4.0 and gnuplot 5.x.
When the series label changes in column 1 it will be added to a string. This string will be used later to plot the legend.
Data: SO8812078.dat
#SeriesName x y
Series1 0 10
Series1 1 11
Series1 2 13
Series2 0 12
Series2 1 13
Series2 2 14
SeriesN 0 14
SeriesN 1 19
Script: (works with gnuplot>=4.4.0, March 2010)
### take legend from column
reset
FILE = "SO8812078.dat"
myTitles = ''
set key noautotitle
plot t1='' FILE u (t0=t1,t1=strcol(1),t0 ne t1?myTitles=myTitles.' '.t1:0,$2):3:(words(myTitles)) w lp pt 7 lc var, \
for [i=0:words(myTitles)] 1/0 w lp pt 7 lc i ti word(myTitles,i)
### end of script
Result: (created with gnuplot 4.4.0)