set xtics nomirror rotate by -45
- Author: gary
- Published: Apr 27th, 2012
- Category: visualization
- Comments: None
Rotate xtics in gnuplot
Plotting NFS Reads and Writes from packet trace.
lovebox-4:[~/data/traces] $ tshark -r trace.trc -R nfs > trace.out
lovebox-4:[~/data/traces] $ gnuplot
gnuplot> plot "trace.out" u 2:(stringcolumn(8) eq "WRITE" ? $1:0/0 ) lc 2 t "WRITES" w points, "" u 2:(stringcolumn(8) eq "READ" ? $1:0/0) lc 3 t "READS" w dots
gnuplot> set term png
gnuplot> set output "trace.png"
gnuplot> replot
- Author: gary
- Published: Jun 23rd, 2011
- Category: visualization
- Comments: None
Changing the implicit x axis in time-series plots.
Quite often I’ll be plotting out values from some kernel counter or other, that has been collected over time. Typically what we want to then do is to plot that counters’ value over time.
In such a case, I typically have a plot command that looks like this
gnuplot> plot "somefile.out" using 3 with lines
Gnuplot will then autogenerate an x coordinate for me, and the value will start at 1 and increase with each line that is plot.

Let’s pretend that each statistic is collected at a 3 hour interval over many days, and I want to present the chart with days as the metric.
I can do that using the $0 value, which in this case is the implicit x coordinate. I can do something like this.
gnuplot> plot "somefile.out using (($0*3)/24):3 with lines
- Author: gary
- Published: Jun 20th, 2011
- Category: visualization
- Comments: None
Use “every” keyword to skip over table preamble.
So, it’s often the case that I’ll want to use gnuplot to make a plot of some data inside a file, which takes the format of a report. Typically there will be some preamble, a description of the columns or whatever, followed by the table that we’re interested in.
For example, I want to plot the data in a file that looks a little like this. Actually a lot like this.
42 Run warming up at 0.269 seconds 43 Run starting at 600.276 seconds 44 Stopping on signal 15 45 Run ramp down at 11074.376 seconds 46 Run finished at 11075.936 seconds 47 48 IOPs: 2999.07 49 I/Os during measurement: 31412590 50 Reads: 12389229 51 Writes: 19023361 52 Run Length: 10474.100 seconds 53 54 55 SPC-1 comparison data. Invalid if response time > 30mS. 56 May not be predictive of real SPC-1 latency. NetApp Confidential. 57 invl i/o resp resp read write fifo 58 rate time max time time time 59 08:24:52.867 1 3004.07 12.11 192.10 28.01 1.74 2.73 60 08:25:52.767 2 2997.96 12.79 138.44 29.86 1.78 0.92 61 08:26:52.667 3 3006.04 13.59 207.66 31.36 2.01 2.59 62 08:27:52.567 4 2938.61 15.23 202.14 35.35 2.09 56.50 63 08:28:52.467 5 3050.85 23.16 216.12 53.91 3.15 292.74 64 08:29:52.367 6 2994.54 24.10 223.62 56.14 3.28 301.11
The first column here is just the line number from within vim. So, anyway, I know that my table starts on line 59. In gnuplot, I then use the ‘every’ command to skip to line 59, then plot the fourth column of every row thereafter.
gnuplot> plot "data.out.29" using 4 every 1::59 w lp t "29, Avg Response time"
- Author: gary
- Published: May 23rd, 2011
- Category: visualization
- Comments: None
Plot vSCSI trace using conditional argument in gnuplot
Recently we’ve been using VMware’s vSCSI trace tool to capture traces of the IO generated by Windows guest VM’s during user login. The output of vSCSI trace can be transformed into a simple CSV file (normally this is done for replay in ioblazer). Once in this CSV format it’s nice and easy to visualize with gnuplot.
Here is an example of the trace file
#Vscsi Cmd Trace. (Trace Format Version 1) #Serial Number,IO Data Length,Num SG Entries,Command Type,LBN,Time Stamp (microseconds) 2147483692,4096,1,write,24048792,2756778716647 2147483769,4096,1,write,6322464,2756783857269 2147483732,4096,1,write,6234880,2756783857712 2147483711,4096,1,write,6234872,2756783858110 2147483658,4608,2,write,23749656,2756797029103 2147483715,512,1,write,6422064,2756797702520 2147483713,4096,1,write,6322472,2756802107264 2147483766,4096,1,write,6234888,2756802107736
Using the conditional plot argument, I can separate out the reads and writes and plot them separately with their own colour. The conditional syntax is best shown in context. Basically I say plot “vscsi.text”, and for the y-axis use the value in column number five “$5″ if column 4 contains the word “write” stringcolumn(4) eq “write”. Otherwise do nothing ($5:0/0). Use the ‘line color’ 2, which is “Green” and call this series “WRITES”. Then I basically do the same thing but separate out the reads instead.
What we end up with is a plot which has a point for each read or write in the trace file. The y-axis represents the LBA (block address) of the read or write. And the color (Green or Blue) represents whether the operation is a read or a write. Time is effectively on the x-axis. What’s especially nice is that we can see that the accesses are not totally random, and there are clear “bands” where a lot of accesses occur. This is much harder to recognize by just reading the trace file.
gnuplot> plot "vscsi.txt" u :(stringcolumn(4) eq "write" ? $5:0/0) lc 2 t "WRITES" w points, "" u :(stringcolumn(4) eq "read" ? $5:0/0) lc 3 t "READS" w points

It’s so refreshing that a modern tool provides readable output in a format like csv that can be handled by any unix tool, in this case gnuplot. So often we end up with the festering bloated carcass of “text” that is XML.

