Gnuplot: calculated X tic labels for data file without X column [duplicate] - gnuplot

I'm plotting a column of data which represents a time series in gnuplot. Every value represents a time value after 500 iterations / time units. Can I tell gnuplot to multiply the x-values it displays by 500?
I thought this would be a standard problem since every time one has to plot a time series one needs to tell the plotting program what time unit each iteration has.
I don't want to create an extra column with x-values manually, since I have a lot of different data of different length. I don't want to create a x column for everyone of them.

If you have only a single column, gnuplot uses the row number as x value. This can be accessed by the pseudo column 0 and scaled like
plot 'datafile' using ($0*500):1
or equivalently, if you're calling this from a shell script
plot 'datafile' using (column(0)*500):1

Related

Excel - Plot average of two plots with inconsistent time (X) axis

I have managed to plot two different data sets on the same axis however, I'm also looking to plotting another line showing their average.
The main problem is that both data sets have different X (time) values so it's not possible to add an average column at the end and plot that. (See the highlighted row 22 for example, corresponding Time values are different)
Is there any way I can plot an average of two plots on the same axis?
One idea that might work is to place the values of both series, one above the other in two new columns, sort this new data according to time, smooth it, then plot the smoothed combined data. Alternatively, you could do the smoothing by simply plotting the new sorted series, adding a moving average trendline to it, then change the formatting of the new series so that it is no longer visible (but the trendline is). Something like this:
In the above picture, series 3 is the plot of the sorted aggregate data of series 1 and 2. If you change the formatting of series 3 so that there is no line, you get something like this:
For my relatively small mock data sets, the results are admittedly poor (it was based on just 25 data points in each series), but if you have a large amount of closely spaced data, and you play around with the moving average window size, you might get something acceptable. If not, you should probably just interpolate both datasets to obtain two consistent time series.

Highlight points on an Excel Line Graph according to a list

I have 2 data series, which records how much a user is meditating/attentive (out of 100) plotted onto a graph. The x axis is the number of seconds since the start of the experiment, and the y axis shows the value for meditation/attention at that point of time.
I have a 3rd set of data that is a series of key timestamps during the experiment (not exactly matching the timestamps from attention/meditation values).
I want to create a graph where you can compare how the attention/meditation values change at the key points
Whether the key points are highlighted by a line or dots I don't care. I tried adding the 3rd data set as a secondary axis, but it still uses the original x-axis of the main graph and I don't know how to make excel do what I want.
Thanks in advance
You should use an XY Scatter chart, not a line chart. A line chart ignores any numerical value in the X values, treats each X value as a text label, and uses the X values from the first series as X values for all series.
You can format the first two series so that they use lines and not markers, and the third so it uses markers without lines.
You may find this link helpful: superuser.com/questions/825692 You don't need to use the secondary axis, just add another series with tag times and constant 45 value, then format vertical error bars to 100% and horizontal to 0%.

Gnuplot, superimpose curves with splot

I am trying to plot a family of curves in space using gnuplot.
I am trying to do it with for-loops. The data are in 4 columns, and every 20 rows, a new plot starts, e.g., if I do a plot using the 3 and 4 columns, on the row 21, the index in the third column starts again, and the number on the second column increases by one. This pattern repeats, and every 320 rows, the index on the first column increases by one, and all the pattern repeats itself again.
The index in the first column goes from 2.0 to 3.8 whereas the index on the second column goes from 75 to 90.
In my code I tried to set the range limits from 1.8 to 4.2 for one axis, and from 0 to 100 for the second axis.
I wrote the following code
a=0 # this variable indicates how many rows to skip
do for [j=20:38:1]{ # loop for the first column
do for [i=75:90:1]{ # loop for the second column #
splot [1.8:4.2][1:101] "dataforgnuplot" every ::a::a+19 u 1:3:4
w lines title sprintf("%3.2f %3.2f",j/10.0, i);
a=a+20;
}
}
and it generates one curve at a time, but the previous one disappears, I had a look at multiplot, and also was trying with replot, but, I still haven't found how to do that.
You should approach this differently. If you put blank lines in your input file in the right places, and plot the whole file, gnuplot will know exactly when to stop drawing one curve and start the next one.
From the gnuplot documentation:
Single blank records designate discontinuities in a plot; no line will join points separated by a blank records (if they are plotted with a line style).
Two blank records in a row indicate a break between separate data sets. See index (p. 79).
The difference between the two cases is that separate curves which are part of the same data set (one blank line) will be plotted in the same color and with a single entry in the legend. Different data sets will have different colors and separate labels.
It should be easy to change the program which outputs this data if you have control over it, to add the extra blank lines. If you don't control it, a one-or-two-line script should be able to insert the blank lines, either based on the line counts you gave, or by checking the first and second data records.

How to plot graph with calculating average on abscissa in gnuplot

My data-file is formatted as fallows:
100;2.123;4.123
100;2.113;5.213
100;2.544;6.234
100;2.324;4.234
200;2.543;3.123
200;2.543;5.123
...
First column is a parameter of a function, second and third are the result of a function. The values of 2nd and 3rd are different for the same values of 1st column, because of other factors, and I want to plot a graph that calculates arithmetic average for all values from 2nd and 3rd column that have the same 1st.
Is there any way gnuplot can do this?
To calculate the arithmetic average of all values which share the same 1st value, you can use smooth unique. To get the average of all values of the 2nd and 3rd column for the same abscissa, you can use
set datafile separator ';'
plot 'datafile' using 1:(($2+$3)/2.0) smooth unique
That makes the data monotonic in the x-values and then replaces all points with the same abscissa with one point having the averaged y-value.
If e.g. you want only the averaged values of the 2nd columns, you would instead use
plot 'datafile' using 1:2 smooth unique
yes !
First of all replace each ; by a blank then
try this command
plot "your_data_file" using ($1):(($2+$3)/2)

I want to make a scatter graph of the output of ftrace (from kernel)

I want to make a scatter graph of the output of ftrace (from kernel) on asm_do_IRQ..The problem is there are 8000+ entries and I get the results as a single line plot. Is there any way to do a normalisation of the values so that I can get a scatter plot? The values I want to print are as below:
Interrupt Time
uart-pl011 196.98111
Nomadi 196.983246
prcmu 196.983307
dma40 196.983429
dma40 196.984222
Nomadi 196.98642
dma40 196.988922
prcmu 196.988953
since the number of values are huge, excel takes time on the Y axis and plots the number of interrupts on the X axis. But i want the interrupts by name on the Y axis and time on the X axis.
looks like this is not possible. Scatter graphs can only be used to plot two variables, and since one of the axes i want to plot is a string, this is not possible - i can only get a trend, not the exact plots vs time

Resources