1

Current graph

Hi guys, I simply want to plot hourly iperf3 up/down summaries in a graph. I'm thinking hour by hour in a bar chart with one bar being up and another for download speed like this. Spent hours figuring out one bar for sent(up), but not the third received(down). Could a Gnuplot please help me out and please offer any improvements to make it look good? Many thanks!

set term svg size 800,600 fname "Helvetica Neue" fsize 9 rounded dashed
set xdata time
set timefmt "%s"
set format x "%H\n%Y-%m-%d"
# Convert bytes to megabytes
set format y '%.0s%cB'
set style fill solid 0.7 border
plot '-' using 1:2 with boxes
1450848960 285806.25 206760
1450849177 169618.75 149460
1450850400 114761.625 101802.375
1450854001 66813.125 61197.375
1450857600 754362.5 580135
1450861200 21886.375 19150.5
1450864800 69255.875 63496.5
1450868400 60622.625 45791
1450872000 802862.5 628208.75
1450875600 818066.25 630898.75
1450879200 860511.25 646103.75
1450882800 841318.75 605322.5
1450886400 717462.5 609187.5
1450890000 768860 629053.75
1450893600 825708.75 595426.25
1450897200 826900 635977.5
1450900800 747992.5 582123.75
1450904400 747561.25 577085
1450908000 782548.75 542241.25
1450911600 817128.75 632105
1450915200 842408.75 605215
1450918800 808897.5 644612.5
1450922400 737481.25 551455
1450926000 789057.5 612383.75
1450929600 849720 639773.75

If there any better ways of trying to plot up/down bandwidth, please let me know. Here is my script I'm using to produce the above GNUplot commands.

Community
  • 1
  • 1
hendry
  • 9,725
  • 18
  • 81
  • 139

2 Answers2

1

When using the boxes plotting style you must manually arrange the boxes to be beside each other. In the following example I use the gnuplot heredoc (available since version 5) for the inline data, so I can reuse it:

$data <<EOD
1450849177 169618.75 149460
1450850400 114761.625 101802.375
1450854001 66813.125 61197.375
1450857600 754362.5 580135
1450861200 21886.375 19150.5
1450864800 69255.875 63496.5
1450868400 60622.625 45791
1450872000 802862.5 628208.75
1450875600 818066.25 630898.75
1450879200 860511.25 646103.75
1450882800 841318.75 605322.5
1450886400 717462.5 609187.5
1450890000 768860 629053.75
1450893600 825708.75 595426.25
1450897200 826900 635977.5
1450900800 747992.5 582123.75
1450904400 747561.25 577085
1450908000 782548.75 542241.25
1450911600 817128.75 632105
1450915200 842408.75 605215
1450918800 808897.5 644612.5
1450922400 737481.25 551455
1450926000 789057.5 612383.75
1450929600 849720 639773.75
EOD

set term svg size 800,600 fname "Helvetica Neue" fsize 9 rounded dashed
set xdata time
set timefmt '%s'
set style fill solid 0.7 border
set boxwidth 1800 absolute
plot $data using (timecolumn(1) - 1800):2 with boxes title 'up',\
     '' using 1:2 with boxes title 'down'
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • Thank you! Can you explain the use of "1800" value especially with timecolumn? Tbh in your example the formatting of the time isn't right. – hendry Dec 27 '15 at 01:58
  • 1800 is half an hour in seconds. I know, that the output time format is wrong, but I removed all settings which are irrelevant for the question – Christoph Dec 27 '15 at 11:42
1

As you want two plot two different data sets (i.e., up and down bandwith), your approach reading from stdin (plot '-' ...) will not work - unless you provide the input data twice. For more details see this SO-question.

Therefore, I suggest writing the input data to a temporary file tempin.
Plotting is now very easy and using histograms allows automatic clustering of the input:

set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9
set xtic rotate by -45 scale 0 font ",8"
set key top left

# Convert bytes to megabytes
set format y '%.0s%cB'

plot 'tempin' using 2:xticlabels(strftime("%H:00 %Y-%m-%d",column(1)-946684800)) t 'up', '' u 3 t 'down'

The output looks like this enter image description here

Note that I have tested this examples with gnuplot 4.4. If you are using gnuplot 5.0, you might have to change strftime("%H:00 %Y-%m-%d",column(1)-946684800) to strftime("%H:00 %Y-%m-%d",column(1)) as the time 0 has been changed from '1/1/2000' to '1/1/1970'.
(Final remark: Just for the case that you want to publish your results, there should be a blank space between numbers and units: 700kB -> 700 kB.)

Community
  • 1
  • 1
F. Knorr
  • 3,045
  • 15
  • 22
  • Thank you! With @Christoph's heredoc I think I have a good solution: https://github.com/kaihendry/iperf3chart/blob/master/plot.sh – hendry Dec 27 '15 at 04:29