How to plot only max values for yerrorbars in Gnuplot? - gnuplot

I have this plot where I show the average values and the standard deviation. The problem is that there is a high +/- error on some lines and I would like to show only the max values for the standard deviation. So the plot can be more clear. Now I am using linespoints and yerrorbars and the plot looks like below:
As you can see the orange and green lines vary a lot. I would like to show only the max values for them so the plot becomes more clear. The script that I am using is below:
plot \
t=0 "throughput-vs-networkbuffer-500K-8reducers-all.csv" every 30 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(8)) skip 2 notitle "no pre-agg" with linespoints lc rgb '#E02F44' lt 1 lw 1.0 ps 0.7 pt 2 pi 30 axis x1y1 \
,t=0 "throughput-vs-networkbuffer-500K-8reducers-all.csv" every 30 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(8)):(column(9)) skip 2 title "no pre-agg" with yerrorbars lc rgb '#E02F44' lt 1 lw 1.0 ps 0.7 pt 2 pi 30 axis x1y1 \
,t=0 "netBuffer-20K-200K-20K-8local-8global-onephase-all.csv" every 28 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)) skip 2 notitle "local mini-batch" with linespoints lc rgb '#008000' lt 1 lw 1.0 ps 0.6 pt 6 pi 28 axis x1y1 \
,t=0 "netBuffer-20K-200K-20K-8local-8global-onephase-all.csv" every 28 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)):(column(3)) skip 2 title "local mini-batch" with yerrorbars lc rgb '#008000' lt 1 lw 1.0 ps 0.6 pt 6 pi 28 axis x1y1 \
,t=0 "netBuffer-20K-200K-20K-8local-8global-twophase-all.csv" every 26 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)) skip 2 notitle "local agg 2-phases" with linespoints lc rgb '#FF780A' lt 1 lw 1.0 ps 0.6 pt 8 pi 26 axis x1y1 \
,t=0 "netBuffer-20K-200K-20K-8local-8global-twophase-all.csv" every 26 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)):(column(3)) skip 2 title "local agg 2-phases" with yerrorbars lc rgb '#FF780A' lt 1 lw 1.0 ps 0.6 pt 8 pi 26 axis x1y1 \
,t=0 "netBuffer-vs-latency-20K-200K-20K-8adcom-8reducers-all.csv" every 24 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)) skip 2 notitle "AdCom pre-agg" with linespoints lc rgb '#3274D9' lt 1 lw 1.0 ps 0.6 pt 5 pi 24 axis x1y1 \
,t=0 "netBuffer-vs-latency-20K-200K-20K-8adcom-8reducers-all.csv" every 24 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)):(column(3)) skip 2 title "AdCom pre-agg" with yerrorbars lc rgb '#3274D9' lt 1 lw 1.0 ps 0.6 pt 5 pi 24 axis x1y1 \
I improved it by adding 4 columns where the third is only the average and the fourth is the average + the standard deviation:
X:(column(2)):(column(2)):(column(2) + column(3))
However, if there is a way more elegant to do it I appreciate any help!

Here is a minimal example for half an error bar using with vectors and set style arrow.
Although, I'm not sure whether it is "experimentally acceptable" to just display "half" an error bar.
Code:
### "half" yerrorbars
reset session
$Data <<EOD
# x y yerr
1 0.10 0.05
2 0.20 0.10
3 0.45 0.21
4 0.67 0.28
5 0.44 0.11
EOD
unset key
set xrange[0:6]
set style arrow 1 size 0.1,90 lc "red"
plot $Data u 1:2 w lp pt 7, \
'' u 1:2:(0):3 w vectors as 1
### end of code
Result:

Related

xtic and xticlabels for plotting strings in x-axis tics in Gnuplot

My data file is given below
ExpData.dat
### Units mg/g
### Col 1-4: Users 1-4
### Col 5-8: Standard 1
### Col 9-12: Standard 2
### Col 13-16: Standard 3
### Col 17-20: Standard 4
### Col 21-24: Standard 5
### Col 25-28: Standard 6
## User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4
User-1 User-2 User-3 User-4 10.07 9.92 9.79 9.68 19.78 19.90 19.38 19.22 39.43 38.35 37.55 37.75 48.95 47.81 46.56 46.23 56.11 56.32 55.04 55.44 67.98 69.39 67.98 67.64
User-1 User-2 User-3 User-4 10.08 9.91 9.82 9.63 19.79 19.92 19.34 19.22 39.45 38.37 37.57 37.70 48.90 47.79 46.58 46.27 56.13 56.35 55.18 55.51 68.02 69.45 67.78 67.60
User-1 User-2 User-3 User-4 10.02 9.92 9.76 9.64 19.75 19.91 19.33 19.25 39.41 38.41 37.58 37.68 48.92 47.81 46.63 46.24 56.13 56.41 55.27 55.63 68.00 69.38 67.86 67.68
User-1 User-2 User-3 User-4 10.04 9.92 9.86 9.64 19.79 19.93 19.33 19.21 39.45 38.35 37.57 37.61 48.92 47.78 46.68 46.26 56.13 56.34 55.02 55.57 68.04 69.42 67.68 67.83
User-1 User-2 User-3 User-4 10.01 9.89 9.76 9.69 19.74 19.94 19.30 19.20 39.47 38.34 37.53 37.78 48.97 47.81 46.74 46.22 56.18 56.37 55.10 55.46 68.12 69.41 67.76 67.44
User-1 User-2 User-3 User-4 10.06 9.88 9.79 9.71 19.79 19.94 19.35 19.20 39.49 38.41 37.58 37.72 48.90 47.81 46.64 46.29 56.14 56.35 54.98 55.50 68.12 69.38 68.03 67.72
Now I wish to have a scatter plot with User-1, User-2, User-3 and User-4 as x-tics. Seems to be quite easy when plotting a histogram but I am getting a small issue while plotting the scatter plot. The test code for plotting the data only for User-1 and User-2 is given below (User-1 and User-2 as x-tics)
##
##
reset session
##
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 4in,3in
set output "ExpData.eps"
#
set xtics out scale 1.5
set ytics out scale 1.5
set tics font ", 14"
set xlabel "Users" font ",16"
set ylabel "mg U/g" font ",16"
set key inside top right title "Experimental Data" font ",14"
set yrange [0:75]
#
plot 'ExpData.dat' u 5:xtic(1) w points pt 10 ps 1.50 lt rgb "#0000FF" notitle, \
'' u 9:xticlabels(1) w points pt 10 ps 1.50 lt rgb "#006400" notitle, \
'' u 13:xticlabels(1) w points pt 10 ps 1.50 lt rgb "#9932CC" notitle, \
'' u 17:xticlabels(1) w points pt 10 ps 1.50 lt rgb "#9932CC" notitle, \
'' u 21:xticlabels(1) w points pt 10 ps 1.50 lt rgb "#FF0000" notitle, \
'' u 25:xticlabels(1) w points pt 10 ps 1.50 lt rgb "#FFD700" notitle, \
###
'' u 6:xtic(2) w points pt 8 ps 1.50 lt rgb "#0000FF" notitle, \
'' u 10:xticlabels(2) w points pt 8 ps 1.50 lt rgb "#006400" notitle, \
'' u 14:xticlabels(2) w points pt 8 ps 1.50 lt rgb "#9932CC" notitle, \
'' u 18:xticlabels(2) w points pt 8 ps 1.50 lt rgb "#9932CC" notitle, \
'' u 22:xticlabels(2) w points pt 8 ps 1.50 lt rgb "#FF0000" notitle, \
'' u 26:xticlabels(2) w points pt 8 ps 1.50 lt rgb "#FFD700" notitle, \
###
The code ends with the error "invalid command". Can anybody suggest if the data file or the code has a problem.
Revision of question after response of #theozh
What I need is
i). There should be only 4 tics in x-axis; User-1, User-2, User-3 and User-4.
ii). For User-1, there should be 6 sets of 6 points plotted at different y-range (Col 5, 9, 13, 17, 21 and 25 for User-1). For each column, pointtype is already defined in the code. For example for User-1
plot 'ExpData.dat' u 5:xtic(1) w p pt 10 ps 1.50 lt rgb "#0000FF", \
'' u 9:xtic(1) w p pt 10 ps 1.50 lt rgb "#006400", \
'' u 13:xtic(1) w p pt 10 ps 1.50 lt rgb "#9932CC", \
'' u 17:xtic(1) w p pt 10 ps 1.50 lt rgb "#9932CC", \
'' u 21:xtic(1) w p pt 10 ps 1.50 lt rgb "#FF0000", \
'' u 25:xtic(1) w p pt 10 ps 1.50 lt rgb "#FFD700", \
But it leads to 6 tics of User-1 and not a single tic.
iii). Complete code is given below but it gives 6 tics of User-4 only.
##
##
reset session
##
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 4in,3in
set output "ExpData.eps"
# FOR CUSTOM LINESTYLES
set style line 1 lt 2 lw 4 lc rgb "#0000FF"
set style line 2 lt 2 lw 4 lc rgb "#006400"
set style line 3 lt 2 lw 4 lc rgb "#9932CC"
set style line 4 lt 2 lw 4 lc rgb "#120A8F"
set style line 5 lt 2 lw 4 lc rgb "#FF0000"
set style line 6 lt 2 lw 4 lc rgb "#FFD700"
set style line 7 lt 2 lw 4 lc rgb "#8470FF"
set style line 8 lt 2 lw 4 lc rgb "#5D478B"
set style line 9 lt 2 lw 4 lc rgb "#9370DB"
set style line 10 lt 2 lw 4 lc rgb "black"
set key samplen 4 spacing 1.4 font ",14" width -2
#
set xtics out scale 1.5
set ytics out scale 1.5
set tics font ", 14"
set xlabel "Users" font ",16"
set ylabel "mg/g" font ",16"
set key inside bottom right spacing 1.35 font ",12" noautotitle
set key title "Experimental Data" font ",14"
set yrange [0:75]
#
plot 'ExpData.dat' u 5:xtic(1) w p pt 10 ps 1.50 lt rgb "#0000FF", \
'' u 9:xtic(1) w p pt 10 ps 1.50 lt rgb "#006400", \
'' u 13:xtic(1) w p pt 10 ps 1.50 lt rgb "#9932CC", \
'' u 17:xtic(1) w p pt 10 ps 1.50 lt rgb "#9932CC", \
'' u 21:xtic(1) w p pt 10 ps 1.50 lt rgb "#FF0000", \
'' u 25:xtic(1) w p pt 10 ps 1.50 lt rgb "#FFD700", \
'' u 6:xtic(2) w p pt 8 ps 1.50 lt rgb "#0000FF", \
'' u 10:xtic(2) w p pt 8 ps 1.50 lt rgb "#006400", \
'' u 14:xtic(2) w p pt 8 ps 1.50 lt rgb "#9932CC", \
'' u 18:xtic(2) w p pt 8 ps 1.50 lt rgb "#9932CC", \
'' u 22:xtic(2) w p pt 8 ps 1.50 lt rgb "#FF0000", \
'' u 26:xtic(2) w p pt 8 ps 1.50 lt rgb "#FFD700", \
'' u 7:xtic(3) w p pt 6 ps 1.50 lt rgb "#0000FF", \
'' u 11:xtic(3) w p pt 6 ps 1.50 lt rgb "#006400", \
'' u 15:xtic(3) w p pt 6 ps 1.50 lt rgb "#9932CC", \
'' u 19:xtic(3) w p pt 6 ps 1.50 lt rgb "#9932CC", \
'' u 23:xtic(3) w p pt 6 ps 1.50 lt rgb "#FF0000", \
'' u 27:xtic(3) w p pt 6 ps 1.50 lt rgb "#FFD700", \
'' u 8:xtic(4) w p pt 4 ps 1.50 lt rgb "#0000FF", \
'' u 12:xtic(4) w p pt 4 ps 1.50 lt rgb "#006400", \
'' u 16:xtic(4) w p pt 4 ps 1.50 lt rgb "#9932CC", \
'' u 20:xtic(4) w p pt 4 ps 1.50 lt rgb "#9932CC", \
'' u 24:xtic(4) w p pt 4 ps 1.50 lt rgb "#FF0000", \
'' u 28:xtic(4) w p pt 4 ps 1.50 lt rgb "#FFD700"
### End of code
Your problem is here:
'' u 25:xticlabels(1) w points pt 10 ps 1.50 lt rgb "#FFD700" notitle, \
###
'' u 6:xtic(2) w points pt 8 ps 1.50 lt rgb "#0000FF" notitle, \
The character \ continues line 1. If you start line 2 with #, this will be a comment.
If you do not end this line with \, line 3 will be a new command, but '' u 6:... is an invalid command because it is not "connected" anymore to the original plot command. But even if you add a \ at the end of line 2, the whole rest of the lines will be interpreted as a comment. Check help comments.
So, remove the ###. It might be nice for visual structuring and formatting but does not work within a plot command (only at the very end).
By the way, you can shorten some commands which makes you plotting command shorter and clearer.
xticlabels() --> xtic()
with points --> w p
set key noautotile instead of repeating notitle in each sub-plot command.
That's how you remove the error. But something else on your plot seems to be incorrect. Maybe you can explain in more detail how you want the xtic labels with the users.
Edit: (after OP editing the question)
You can use loops in plot commands which might make your life easier and shorter. You can loop the user and the number of the plot for each user. You define some functions for your pointtype, the color and the data column. And then use variable pointtype pt var and variable linecolor lc rgb var. Check help variable. I tried to do this with your data.
Although, I doubt you want to apply the same color 0x9932cc twice, but this can easily be changed.
Code:
### plot command does not allow for commented lines inbetween
reset session
$Data <<EOD
## User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4 User 1 User 2 User 3 User 4
User-1 User-2 User-3 User-4 10.07 9.92 9.79 9.68 19.78 19.90 19.38 19.22 39.43 38.35 37.55 37.75 48.95 47.81 46.56 46.23 56.11 56.32 55.04 55.44 67.98 69.39 67.98 67.64
User-1 User-2 User-3 User-4 10.08 9.91 9.82 9.63 19.79 19.92 19.34 19.22 39.45 38.37 37.57 37.70 48.90 47.79 46.58 46.27 56.13 56.35 55.18 55.51 68.02 69.45 67.78 67.60
User-1 User-2 User-3 User-4 10.02 9.92 9.76 9.64 19.75 19.91 19.33 19.25 39.41 38.41 37.58 37.68 48.92 47.81 46.63 46.24 56.13 56.41 55.27 55.63 68.00 69.38 67.86 67.68
User-1 User-2 User-3 User-4 10.04 9.92 9.86 9.64 19.79 19.93 19.33 19.21 39.45 38.35 37.57 37.61 48.92 47.78 46.68 46.26 56.13 56.34 55.02 55.57 68.04 69.42 67.68 67.83
User-1 User-2 User-3 User-4 10.01 9.89 9.76 9.69 19.74 19.94 19.30 19.20 39.47 38.34 37.53 37.78 48.97 47.81 46.74 46.22 56.18 56.37 55.10 55.46 68.12 69.41 67.76 67.44
User-1 User-2 User-3 User-4 10.06 9.88 9.79 9.71 19.79 19.94 19.35 19.20 39.49 38.41 37.58 37.72 48.90 47.81 46.64 46.29 56.14 56.35 54.98 55.50 68.12 69.38 68.03 67.72
EOD
set xtics out scale 1.5
set ytics out scale 1.5
set tics font ", 14"
set xlabel "Users" font ",16"
set ylabel "mg U/g" font ",16"
set key inside top right title "Experimental Data" font ",14" noautotitle
set yrange [0:75]
myPoints(n) = int(word("10 8 6 4",n)) # different pointtypes
myColor(n) = int(word("0x0000ff 0x006400 0x9932cc 0x9932cc 0xff0000 0xffd700",i))
myColumn(user,n) = column(user + n*4)
set xrange[0.5:4.5]
plot for [user=1:4] for [i=1:6] \
$Data u (user):(myColumn(user,i)):(myPoints(user)):(myColor(i)):xtic(user) \
w p pt var ps 1.50 lc rgb var
### end of code
Result:

How to stack impulses in Gnuplot?

I am using Gnuplot to show the precipitation measured during the last 13 monthts. Data is read from two data files, rain.dat and snow.dat. I use impulses, but on days with both rain and snow the impulses are plotted over each other. It had been better if the impulses were stacked.
#!/usr/bin/gnuplot -persist
set xdata time
set timefmt "%d.%m.%Y"
set ylabel "Precipitation (mm)"
set xrange ["01.`date --date="1 year ago" +%m.%Y`":"01`date --date="1 month" +.%m.%Y`"]
set xtics "01.`date --date="1 year ago" +%m.%Y`",2800000, \
"01.`date --date="now 1 month" +%m.%Y`" offset 3,0.2
set format x "%b"
set style line 100 lt 3 lc rgb "gray" lw 0.5
set style line 101 lt 3 lc rgb "gray" lw 0.5
set grid back xtics ytics mytics ls 100, ls 100, ls 101
set terminal png size 1000,200
set output 'precipitation.png'
plot 'rain.dat' using 1:2 title 'Rain' w impulses lt rgb '#ff0000' lw 4 , \
'snow.dat' using 1:2 title 'Snow' w impulses lt rgb '#0000ff' lw 2
rain.dat:
16.02.2021 8
22.02.2021 6
04.03.2021 10
08.03.2021 13
14.03.2021 5
snow.dat:
19.02.2021 19
22.02.2021 10
04.03.2021 14
12.03.2021 8
How can impulses be stacked with Gnuplot?
As #Ethan already mentioned, with impulses will always start at 0. If you don't mind some little extra effort, you can mimic "stacking" impulses if you first plot the sum of rain and snow with the "snow color", and then plot rain alone with the "rain color" on top of it.
But how do you get the sum of rain and snow?
plot your datablocks (or files) into the temporary datablock $Temp.
plot datablock $Temp into the datablock $SnowAndRain using the option smooth frequency which sums up snow and rain for each day. Check help smooth.
Script: (works for gnuplot>=5.2.0, Sept. 2017)
### "stacked" impulses
reset session
$Rain <<EOD
16.02.2021 8
22.02.2021 6
04.03.2021 10
08.03.2021 13
14.03.2021 5
EOD
$Snow <<EOD
19.02.2021 19
22.02.2021 10
04.03.2021 14
12.03.2021 8
EOD
myTimeFmt = "%d.%m.%Y"
set table $Temp
plot $Snow u (sprintf("%.0f",timecolumn(1,myTimeFmt))):2 w table
plot $Rain u (sprintf("%.0f",timecolumn(1,myTimeFmt))):2 w table
set table $SnowAndRain
set format x "%.0f"
plot $Temp u 1:2 smooth freq
unset table
set format x "%d %b" timedate
plot $SnowAndRain u 1:2 w impulses lw 4 lc "blue" title 'Snow', \
$Rain u (timecolumn(1,myTimeFmt)):2 w impulses lc "red" lw 4 title 'Rain', \
### end of script
Result:
Addition:
A bit more cumbersome solution which seem to work with gnuplot 5.0.0 (at least with Win10). I hope somebody can simplify this.
Script: (tested with Win10 gnuplot 5.0.0. Same result as above)
### "stacked" impulses (should work with gnuplot 5.0.0)
reset session
$Rain <<EOD
16.02.2021 8
22.02.2021 6
04.03.2021 10
08.03.2021 13
14.03.2021 5
EOD
$Snow <<EOD
19.02.2021 19
22.02.2021 10
04.03.2021 14
12.03.2021 8
EOD
myTimeFmt = "%d.%m.%Y"
set table $Temp
plot $Snow u (t=timecolumn(1,myTimeFmt)/1e5,int(t)):2:((t-int(t))*1e5) w table
plot $Rain u (t=timecolumn(1,myTimeFmt)/1e5,int(t)):2:((t-int(t))*1e5) w table
unset table
set table $SnowAndRain
set format x "%.0f"
plot $Temp u ($1*1e5+$3):2 smooth freq
unset table
set format x "%d %b" timedate
plot $SnowAndRain u 1:2 w impulses lw 4 lc "blue" title 'Snow', \
$Rain u (timecolumn(1,myTimeFmt)):2 w impulses lc "red" lw 4 title 'Rain'
### end of script
Impulses cannot be stacked. By definition they extend from y=0 to some non-zero y value.
If the two data sets were sampled at the same set of x coordinates then you could use the stacked histogram plot mode, but that isn't the case here.
How about back-to-back impulses rather than stacked impulses?
$RAIN << EOD
16.02.2021 8
22.02.2021 6
04.03.2021 10
08.03.2021 13
14.03.2021 5
EOD
$SNOW << EOD
19.02.2021 19
22.02.2021 10
04.03.2021 14
12.03.2021 8
EOD
set xzeroaxis
plot $RAIN using 1:2 with impulse lw 3, \
$SNOW using 1:(-$2) with impulse lw 3
I have tried to make a simplification to #theozh's answer, but some of the pulses are slightly displaced in time. #theozh has a much better solution of my problem.
reset session
$Rain <<EOD
16.02.2021 8
22.02.2021 6
04.03.2021 10
08.03.2021 13
14.03.2021 5
EOD
$Snow <<EOD
19.02.2021 19
22.02.2021 10
04.03.2021 14
12.03.2021 8
EOD
myTimeFmt = "%d.%m.%Y"
set table $Temp
plot $Snow u (timecolumn(1,myTimeFmt)):2 w table
plot $Rain u (timecolumn(1,myTimeFmt)):2 w table
unset table
set table $SnowAndRain
plot $Temp u 1:2 smooth freq
unset table
set format x "%d %b" timedate
plot $SnowAndRain u 1:2 w impulses lw 4 lc "blue" title 'Snow', \
$Rain u (timecolumn(1,myTimeFmt)):2 w impulses lc "red" lw 4 title 'Rain', \
### end of code
Addition:
The rain and snow pulses are drawn on top of each other if $Rain is written to table $RainTemp using (timecolumn(1,myTimeFmt)):2 before plotting the the graph. But still the timing is bit incorrect.
reset session
$Rain <<EOD
16.02.2021 8
22.02.2021 6
04.03.2021 10
08.03.2021 13
14.03.2021 5
EOD
$Snow <<EOD
19.02.2021 19
22.02.2021 10
04.03.2021 14
12.03.2021 8
EOD
myTimeFmt = "%d.%m.%Y"
set table $Temp
plot $Snow u (timecolumn(1,myTimeFmt)):2 w table
plot $Rain u (timecolumn(1,myTimeFmt)):2 w table
unset table
set table $SnowAndRain
plot $Temp u 1:2 smooth freq
unset table
set table $RainTemp
plot $Rain u (timecolumn(1,myTimeFmt)):2 w table
unset table
set format x "%d %b" timedate
plot $SnowAndRain u 1:2 w impulses lw 4 lc "blue" title 'Snow', \
$RainTemp u 1:2 w impulses lw 4 lc "red" title 'Rain'

Struggling to merge multiples charts in one and keeping it clear with Gnuplot

before I had four charts in Gnuplot to convey my information about my data. However, it was required for me to show everything in one unique chart since all charts are conveying related data but on different scales. For instance, for scale (8:8) I use X, scale (16:16) I use +, scale (8:16) I use square, and scale (8:24) I use a circle.
The problem that I stated is that it will become messy eventually and the chart will look very dirty in terms of readable. But, maybe, Gnuplot offers a better solution to me that I still don't know. Here is my Gnuplot code and the data files can be found here.
#!/usr/bin/gnuplot
reset session
set style line 1 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner input throughput - 8combines.8reducers
set style line 2 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner output throughput - 8combines.8reducers
set style line 3 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # static-combiner input throughput - 8combines.8reducers
set style line 4 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # static-combiner output throughput - 8combines.8reducers
set style line 5 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # no-combiner input throughput - 8combines.8reducers
set style line 6 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # no-combiner output throughput - 8combines.8reducers
set style line 7 lc rgb '#008000' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner average processing latency - 8combines.8reducers
set style line 8 lc rgb '#9ACD32' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner 99th percentile processing latency - 8combines.8reducers
set style line 9 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner input throughput - 16combines.16reducers
set style line 10 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner output throughput - 16combines.16reducers
set style line 11 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # static-combiner input throughput - 16combines.16reducers
set style line 12 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # static-combiner output throughput - 16combines.16reducers
set style line 13 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # no-combiner input throughput - 16combines.16reducers
set style line 14 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # no-combiner output throughput - 16combines.16reducers
set style line 15 lc rgb '#008000' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner average processing latency - 16reducers.8reducers
set style line 16 lc rgb '#9ACD32' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner 99th percentile processing latency - 16reducers.8reducers
set style line 17 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # auto-combiner input throughput - 8combines.16reducers
set style line 18 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # auto-combiner output throughput - 8combines.16reducers
set style line 19 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # static-combiner input throughput - 8combines.16reducers
set style line 20 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # static-combiner output throughput - 8combines.16reducers
set style line 21 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # no-combiner input throughput - 8combines.16reducers
set style line 22 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # no-combiner output throughput - 8combines.16reducers
set style line 23 lc rgb '#008000' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # auto-combiner average processing latency - 8combines.16reducers
set style line 24 lc rgb '#9ACD32' lt 1 lw 1.0 ps 0.3 pt 5 pi 15 # auto-combiner 99th percentile processing latency - 8combines.16reducers
set style line 25 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # auto-combiner input throughput - 8combines.24reducers
set style line 26 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # auto-combiner output throughput - 8combines.24reducers
set style line 27 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # static-combiner input throughput - 8combines.24reducers
set style line 28 lc rgb '#FF780A' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # static-combiner output throughput - 8combines.24reducers
set style line 29 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # no-combiner input throughput - 8combines.24reducers
set style line 30 lc rgb '#E02F44' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # no-combiner output throughput - 8combines.24reducers
set style line 31 lc rgb '#008000' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # auto-combiner average processing latency - 8combines.24reducers
set style line 32 lc rgb '#9ACD32' lt 1 lw 1.0 ps 0.35 pt 7 pi 15 # auto-combiner 99th percentile processing latency - 8combines.24reducers
set term pdfcairo size 5.0in,3.5in
set pointintervalbox 0
set datafile separator ','
set output "efficiency-throughput-networkbuffer-TaxiRideNYC-500K-merged.pdf"
set title "Efficiency evaluation: throughput vs. network buffer usage\nworkload of 500K rec/sec and different topologies" font ",16" offset 0,0.5,0
myTimeFmt = "%Y-%m-%d %H:%M:%S"
set xtics nomirror
set key under center maxrows 1 horizontal
set key font ",9"
set ylabel "Throughput (K rec/sec)" font ",10" #offset 1,0,0
set xtics font ",8" offset 0,0.5,0
set format x "%tH:%tM" time
set xlabel "time (hour:minute)" font ",10" offset 0,1,0
set xrange [0:5400]
set yrange [0:7]
set y2label "Combiner buffer usage" font ",10" #offset -1.5,0,0
set y2range [20:100]
set ytics nomirror font ",10"
set y2tics 0, 20 font ",10"
set format y2 "%g%%"
plot t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(6)) skip 2 notitle "auto-combiner avg. buffer usage (8:8)" with linespoints ls 7 axis x1y2 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(6)/1000):(column(7)/1000) skip 2 title "auto-combiner avg. buffer usage (8:8)" with yerrorbars ls 7 axis x1y2 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-static-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "static-combiner input throughput (16:16)" with linespoints ls 11 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-static-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "static-combiner input throughput (16:16)" with yerrorbars ls 11 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-16reducers-static-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "static-combiner input throughput (8:16)" with linespoints ls 19 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-16reducers-static-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "static-combiner input throughput (8:16)" with yerrorbars ls 19 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-24reducers-static-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "static-combiner input throughput (8:24)" with linespoints ls 27 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-24reducers-static-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "static-combiner input throughput (8:24)" with yerrorbars ls 27 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-static-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "static-combiner input throughput (8:8)" with linespoints ls 3 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-static-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "static-combiner input throughput (8:8)" with yerrorbars ls 3 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-16reducers-no-combiner-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000) skip 2 notitle "no-combiner input throughput (8:16)" with linespoints ls 21 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-16reducers-no-combiner-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000):(column(5)/1000) skip 2 title "no-combiner input throughput (8:16)" with yerrorbars ls 21 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-no-combiner-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000) skip 2 notitle "no-combiner throughput (16:16)" with linespoints ls 13 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-no-combiner-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000):(column(5)/1000) skip 2 title "no-combiner throughput (16:16)" with yerrorbars ls 13 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-24reducers-no-combiner-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000) skip 2 notitle "no-combiner input throughput (8:24)" with linespoints ls 29 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-24reducers-no-combiner-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000):(column(5)/1000) skip 2 title "no-combiner input throughput (8:24)" with yerrorbars ls 29 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-no-combiner-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000) skip 2 notitle "no-combiner throughput (8:8)" with linespoints ls 5 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-no-combiner-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(4)/1000):(column(5)/1000) skip 2 title "no-combiner throughput (8:8)" with yerrorbars ls 5 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "auto-combiner input throughput (16:16)" with linespoints ls 9 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "auto-combiner input throughput (16:16)" with yerrorbars ls 9 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "auto-combiner input throughput (8:8)" with linespoints ls 1 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "auto-combiner input throughput (8:8)" with yerrorbars ls 1 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-16reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "auto-combiner input throughput (8:16)" with linespoints ls 17 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-16reducers-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "auto-combiner input throughput (8:16)" with yerrorbars ls 17 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-24reducers-all.csv" u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 notitle "auto-combiner input throughput (8:24)" with linespoints ls 25 axis x1y1 \
, t=0 "throughput-vs-networkbuffer-500K-8combiners-24reducers-all.csv" every 10 u (t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000):(column(3)/1000) skip 2 title "auto-combiner input throughput (8:24)" with yerrorbars ls 25 axis x1y1 \
The first thing that I would ask is to merge the legends into groups of X, +, squares, and circles. However, I think that the chart is still a big mess. How would one show all information that I have in a clear way using only one chart? I think I will probably have to remove some lines in the end. But I would like to know other alternatives before going to it.
thanks for your suggestions!
I ended up using the fence plot constructed with separate parametric surfaces of Gnuplot 3D with splot available here.

GNUPLOT : how to stop "histeps" from terminating to zero (y=0) at start and endpoints?

I am using the following script for plotting data points from file "delete.dat"
set terminal jpeg
set output "delete_histeps.jpeg"
set title "with histeps"
plot "delete.dat" using 1:2 index 0 pt 7 ps 0.2 lc "black" notitle,\
"delete.dat" using 1:2 index 1 pt 7 ps 0.2 lc "red" notitle,\
"delete.dat" using 1:2 index 2 pt 7 ps 0.2 lc "green" notitle,\
"delete.dat" using 1:2 index 0 with histeps lc "black",\
"delete.dat" using 1:2 index 1 with histeps lc "red",\
"delete.dat" using 1:2 index 2 with histeps lc "green"
and the "delete.dat" file is
1 2
3 4
5 6
7 8
9 10
-1 5
-2 3
-3 4
-4 2
-5 6
5 1
6 2
7 3
8 4
9 5
10 4
11 3
12 12
But the start and end step is dropping to zero, which I don't want. Though for step and fsteps command, the steps begin (end) at the first (last) data point, without dropping down to zero (y=0). Can you please suggest that works like histeps (which keeps data points in the middle of the steps) but does not terminate to zero (like steps or fsteps). I'm also attaching pictures.
If your data points are equidistant (like the ones you provided), an alternative hack would be possible as well by combining fsteps and steps and shifting the x-value by half the point-to-point-distance:
plot "delete.dat" i 0 pt 7 ps 2 lc "black" not, \
'' i 1 pt 7 ps 2 lc "red" not, \
'' i 2 pt 7 ps 2 lc "green" not, \
'' u ($1-1.0):2 i 0 w steps lc "black", '' u ($1+1.0):2 i 0 w fsteps lc "black" not, \
'' u ($1+0.5):2 i 1 w steps lc "red", '' u ($1-0.5):2 i 1 w fsteps lc "red" not, \
'' u ($1-0.5):2 i 2 w steps lc "green", '' u ($1+0.5):2 i 2 w fsteps lc "green" not
The trick here is that steps or fsteps alone would miss either the last or the first point and the line would end in mid-air, therefore both have to be plotted on top of each other with the same plotting style.
One must take care of the correct sign: if x is positive, steps get a downshift and fsteps get an upshift; and vice-versa if x is negative.
My answer is definitely not as "robust" as the one of theozh, but maybe easier to understand.
Well, that's how hispteps, steps, and fsteps have been defined.
Then, you have to create your own steps. A solution could be the following:
Code: (improved version)
### steps like histeps but not dropping to zero
reset session
set colorsequence classic
$Data <<EOD
1 2
3 4
5 6
7 8
9 10
-1 5
-2 3
-3 4
-4 2
-5 6
5 1
6 2
7 3
8 4
9 5
10 4
11 3
12 12
EOD
set table $myStep
do for [i=0:2] {
plot $Data u ($0==0?(x1=x2=$1):(x1=x2,x2=$1),(c=$0,x1+x2)/2.):2 index i w table
plot $Data u 1:2 every ::c index i w table # add last value
plot '+' u ("") every ::::1 w table # add two empty lines
}
unset table
set key top left
plot for [i=0:2] $myStep u 1:2 index i w step lc i lw 3 notitle,\
for [i=0:2] $Data u 1:2 index i w p pt 7 lc i notitle, \
### end of code
Result:

how to define X's label on gnuplot

This is My data :
18_AGT_s 8234.00 8234.00 8234.00
18_MAC_s 8414.36 8308.36 8246.33
9_MAC_r 8414.36 8308.36 8246.33
9_MAC_s 8414.55 8309.55 8246.45
8_MAC_r 8414.55 8309.55 8246.45
8_MAC_s 8414.56 8310.08 8246.47
6_MAC_r 8414.56 8310.08 8246.47
6_MAC_s 8416.19 8310.21 8246.49
1_MAC_r 8416.19 8310.21 8246.49
and here is my gnuplot code :
plot "dat" using ($0+1):2 with linespoints pt 8 ps 2 lt 2 lw 4 lc rgb
"green" title "DMSR","dat" using ($0+1):3 with linespoints pt 5 ps 2
lt 3 lw 4 lc rgb "blue" title "Alarm","dat" using ($0+1):4 with
linespoints pt 6 ps 2 lt 4 lw 4 lc rgb "red" title "Emergency"
and here is my out put :
But In the step part I want to have 18_AGT_s and 18_MAC_s and 9_MAC_s and .... for example on the X part I want to have 18_AGT_s in stand of 1 or I want to have 18_MAC_2 instand of 2 and 9_MAC_r instand of 3 etc. Any help thanks
Use the xticlabels() option with the column number with the labels as argument (1, in this case):
# Optionally rotate labels so they fit
set xtics rotate
plot "dat" using ($0+1):2 with linespoints pt 8 ps 2 lt 2 lw 4 lc rgb \
"green" title "DMSR","dat" using ($0+1):3 with linespoints pt 5 ps 2 \
lt 3 lw 4 lc rgb "blue" title "Alarm","dat" using \
($0+1):4:xticlabels(1) with linespoints pt 6 ps 2 lt 4 lw 4 lc rgb \
"red" title "Emergency"
Here you only need to use it for the last plot instance so that it overwrites the number options.

Resources