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'
Related
I would like to achieve a similar effect in gnuplot.
Here is what I tried:
unset key
set style line 11 lc rgb '#808080' lt 1
set border 3 ls 11
set tics nomirror
set grid
set style line 1 lc rgb '#808080' pt 9 ps 3
set style line 2 lc rgb '#808080' pt 20 ps 3
set style line 3 lc rgb '#BD3828' pt 7 ps 3
set yrange [4:9]
$data << EOD
5 5.1
5.3 6.8
6 6
EOD
$data2 << EOD
5 5
7 7
8 6
EOD
$data3 << EOD
5.5 7
6 6
7 7.1
EOD
plot $data u 1:2 w points ls 1, $data2 u 1:2 w points ls 2, \
$data3 u 1:2 w points ls 3
As we can see, points can be overlapped. Then how can we darken the overlap areas?
A possible solution is to set transparency (e.g., lc rgb '#80808080'), but it will also make both border and filling transparent. So how to set the different fill and border colors for with points?
Another solution is to use set object, but we need to do more work to read data from files.
I think the closest you could come to what you describe is to draw the points in two passes.
First pass: draw using a point type that produces only the outlines (point types N = 4 6 8 10 12 ...).
Second pass: draw using the corresponding point type N+1 that produces only the interior, using the same color but adding an alpha channel value to make it partially transparent.
set print $RAND1
do for [i = 1:50] { print rand(0), rand(0) }
unset print
set print $RAND2
do for [i = 1:50] { print rand(0), rand(0) }
unset print
set pointsize 4
plot $RAND1 with points pt 8 lc rgb "#00b8860b", \
'' with points pt 9 lc rgb "#AAb8860b", \
$RAND2 with points pt 6 lc rgb "#00c04000", \
'' with points pt 7 lc rgb "#AAc04000"
Drawing a step plot leads always to an out of border result.
How to solve the issue? Any ideas? THX!
The MWE is:
reset;set term png small size 500,500;set output 'test.png';
set title 'First step is always drawn out of chart borders ?!?';
unset y2tics;set y2range [0:40];set y2tics 10;set yrange [0:40];set ytics 10 mirror;
set style fill solid 1.00 border;
plot 'test.data' using 1:2 notitle with fillsteps lc rgb 'light-goldenrod', \
'' using 1:3 notitle with fillsteps lc rgb 'gray40', \
'' using 1:4 notitle with fillsteps lc rgb 'web-green', \
'' using 1:5 notitle with fillsteps lc rgb 'light-green';
The result is:
Used software is:
GNUPLOT Version 5.2 patchlevel 8
Ok, now I see your point. Looks like a little bug (or our limited understanding).
I cannot tell right away why this is, but you can avoid it
by adding a line in the beginning which contains the first x value and all y-values are 0.
If you don't want to do this manually, there would be ways to do this automatically with gnuplot.
But I hope there is a simpler solution.
Code:
### plot with fillsteps
reset session
$Data <<EOD
1 0 0 0 0
1 50 35 30 5
2 55 30 20 5
17 51 44 30 12
20 1 1 1 1
EOD
unset y2tics;set y2range [0:40]
set y2tics 10
set yrange [0:40]
set ytics 10 mirror
set style fill solid 1.00 border
unset key
plot $Data u 1:2 w fillsteps lc 'light-goldenrod', \
'' u 1:3 w fillsteps lc 'gray40', \
'' u 1:4 w fillsteps lc 'web-green', \
'' u 1:5 w fillsteps lc 'light-green'
### end of code
Result:
Addition: (automatically duplicate first line, to workaround the bug(!?))
In order to workaround this (what I would call unexpected or a bug) you want to duplicate the first line automatically. There would be certainly different easy ways with external tools, however, which would not guarantee platform-independence. So, here is one of several possible gnuplot-only solutions.
get your file into a datablock (here: $Data) (see gnuplot: load datafile 1:1 into datablock)
print the first line of $Data into a new datablock (here: $Data2) Make sure that the first line is not a header or commented line, i.e. print the first dataline.
append the full datablock $Data again to $Data2.
Data: (Test.dat)
1 50 35 30 5
2 55 30 20 5
17 51 44 30 12
20 1 1 1 1
Code: (Result same as above)
# https://stackoverflow.com/a/67151340/7295599
### plot with filledcurves
reset session
FileToDatablock(f,d) = GPVAL_SYSNAME[1:7] eq "Windows" ? \
sprintf('< echo %s ^<^<EOD & type "%s"',d,f) : \
sprintf('< echo "\%s <<EOD" & cat "%s"',d,f) # Linux/MacOS
FILE = 'Test.dat'
load FileToDatablock(FILE,'$Data')
set print $Data2
print $Data[1] # only first line
print $Data
set print
unset y2tics;set y2range [0:40]
set y2tics 10
set yrange [0:40]
set ytics 10 mirror
set style fill solid 1.00 border
unset key
plot $Data2 u 1:2 every ::0::0 w fillsteps lc 'light-goldenrod', \
'' u 1:2 w fillsteps lc 'light-goldenrod', \
'' u 1:3 w fillsteps lc 'gray40', \
'' u 1:4 w fillsteps lc 'web-green', \
'' u 1:5 w fillsteps lc 'light-green'
### end of code
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:
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.
I have this script to plot data from a CSV file using gnuplot. I want to add 3 vertical lines at different times on the plot to show where I changed the workload of my experiment. I was trying to do it with vector but it was messing the data already plotted. I attached my chart and added manually the vertical blue line as an example of what I want.
#!/usr/bin/gnuplot
# set grid
set key under left maxrows 1
set style line 1 lc rgb '#E02F44' lt 1 lw 1 ps 0.5 pt 7 # input throughput
set style line 2 lc rgb '#FF780A' lt 1 lw 1 ps 0.5 pt 1 # output throughput
set style line 3 lc rgb '#56A64B' lt 1 lw 1 ps 0.5 pt 2 # average processing latency
set style line 4 lc rgb '#000000' lt 1 lw 1 ps 0.5 pt 3 # 99th percentile processing latency
set terminal pdf
set pointintervalbox 0
set datafile separator ','
set output "efficiency-throughput-networkbuffer-baseline-TaxiRideNYC-100Kpersec.pdf"
set title "Throughput vs. processing latency consuming 50K r/s from the New York City (TLC)"
set xlabel "time (minutes)"
set ylabel "Throughput (K rec/sec)"
set y2label "processing latency (seconds)"
set ytics nomirror
set y2tics 0, 1
set xdata time # tells gnuplot the x axis is time data
set timefmt "%Y-%m-%d %H:%M:%S" # specify our time string format
set format x "%M" # otherwise it will show only MM:SS
plot "throughput-latency-increasing.csv" using 1:(column(2)/1000) title "IN throughput" with linespoints ls 1 axis x1y1 \
, "throughput-latency-increasing.csv" using 1:(column(10)/1000) title "OUT throughput" with linespoints ls 2 axis x1y1 \
, "throughput-latency-increasing.csv" using 1:(column(18)/1000) title "avg. latency" with linespoints ls 3 axis x1y2 \
, "throughput-latency-increasing.csv" using 1:(column(26)/1000) title "99th perc. latency" with linespoints ls 4 axis x1y2 \
#, "" using 1:($1):(3):(0) notitle with vectors nohead
My data file is:
"Time","pre_aggregate[0]-IN","pre_aggregate[1]-IN","pre_aggregate[2]-IN","pre_aggregate[3]-IN","pre_aggregate[4]-IN","pre_aggregate[5]-IN","pre_aggregate[6]-IN","pre_aggregate[7]-IN","pre_aggregate[0]-OUT","pre_aggregate[1]-OUT","pre_aggregate[2]-OUT","pre_aggregate[3]-OUT","pre_aggregate[4]-OUT","pre_aggregate[5]-OUT","pre_aggregate[6]-OUT","pre_aggregate[7]-OUT","pre_aggregate[0]-50","pre_aggregate[1]-50","pre_aggregate[2]-50","pre_aggregate[3]-50","pre_aggregate[4]-50","pre_aggregate[5]-50","pre_aggregate[6]-50","pre_aggregate[7]-50","pre_aggregate[0]-99","pre_aggregate[1]-99","pre_aggregate[2]-99","pre_aggregate[3]-99","pre_aggregate[4]-99","pre_aggregate[5]-99","pre_aggregate[6]-99","pre_aggregate[7]-99"
"2020-04-27 10:31:00",1428.05,1274.4666666666667,1364.6166666666666,1384.4666666666667,1327.3,1376.5,1390.9166666666667,1418.35,1428.05,1274.4666666666667,1364.6333333333334,1384.4666666666667,1327.3,1376.5,1390.9166666666667,1418.35,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1
"2020-04-27 10:31:15",1463.5833333333333,1452.3666666666666,1346.7333333333333,1380.3833333333334,1429.4833333333333,1431.6833333333334,1442.85,1425.15,1463.5833333333333,1452.3666666666666,1346.7333333333333,1380.3833333333334,1429.4833333333333,1431.6833333333334,1442.85,1425.15,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1
"2020-04-27 10:31:30",1393.4666666666667,1396.65,1369.55,1381.3833333333334,1336.8,1434.5166666666667,1440.0833333333333,1399.2833333333333,1393.45,1396.65,1369.55,1381.3833333333334,1336.8,1434.5166666666667,1440.0833333333333,1399.2833333333333,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1
"2020-04-27 10:31:45",1404.8833333333334,1448.5333333333333,1313.9,1308.1,1359.6333333333334,1329.5166666666667,1338.4166666666667,1481.5666666666666,1404.8833333333334,1448.5333333333333,1313.9,1308.1,1359.6333333333334,1329.5166666666667,1338.4166666666667,1481.5833333333333,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1
Of course you can plot your lines and labels. In the example below I'm using the newer syntax compared to set xdata time. Which requires timecolumn(1,myTimeFmt) and e.g. set format x "%M" time.
Your date is in double quotes, so you have to define the timeformat using single quotes including the double quotes.
Furthermore, you are using absolute times, so your lines ideally use the same format. You can put it into a datablock. I hope you can adapt the code to your needs.
Code:
### vertical lines with labels on time axis
reset session
$myLines <<EOD
"2020-04-27 10:34:00"
"2020-04-27 10:39:20"
"2020-04-27 10:43:50"
"2020-04-27 10:48:00"
EOD
myTimeFmt = '"%Y-%m-%d %H:%M:%S"'
StartDate = '"2020-04-27 10:30:00"'
EndDate = '"2020-04-27 10:52:00"'
set format x "%M" time
set xrange [strptime(myTimeFmt,StartDate):strptime(myTimeFmt,EndDate)]
yLow = 1.4
yHigh = 3.5
set tmargin screen 0.90
plot '+' u (strptime(myTimeFmt,StartDate)+$0*60):(rand(0)*3+0.5) w l lc rgb "red" notitle, \
$myLines u (timecolumn(1,myTimeFmt)):(yHigh):("Workload\nchanged") w labels right offset -0.5,1.5 not, \
$myLines u (timecolumn(1,myTimeFmt)):(yLow):(0):(yHigh-yLow) w vec lc rgb "blue" lw 2 nohead not
### end of code
Result: