web analytics

Howto create gnuplot cluster histogram charts

In a previous article, I explained how to create rowstacked histograms using gnuplot. In this article, I provide a simple example for creating a cluster histogram using gnuplot.

Data file

We will consider the same example as the previous article about rowstacked histograms. Lets assume we are studying a client/server application. The goal is to decompose the total session time into processing time at the server side, processing time at the client side and latency introduced by network delays.

Using packet capture tools such as tshark in combination with awk and some scripting, one can create text data files that can be fed to gnuplot to produce a cluster histogram.

The data file should look like this :

1 23 2 9 13 
2 25 5 7 12 
3 26 5 3 13 
4 20 6 8 5 
5 23 5 12 15 
6 23 5 12 11 
7 22 9 12 5 
8 24 16 5 8 
9 23 2 12 10 
10 23 15 5 9 

Each row represents one session. The fist column is the session number, (we will not use the second column) the third column is the time consumed by the server, the fourth column shows the time consumed by client-side processing and the fifth column represents the network delays for that particular session.

Drawing histograms

This is a gnuplot script that displays a cluster histogram from our data. This cluster histogram shows the time decomposition for each session.

set terminal jpeg medium 
set output "histo.jpeg"
set boxwidth 0.75 absolute
set style fill solid 1.00 border -1
set style data histogram
set style histogram cluster gap 1
set xtics 1000 nomirror
set ytics 100 nomirror
set mxtics 2
set mytics 2
set ytics 10
set yrange [0:30]
set ylabel "Total time"
set xlabel "Session number"

plot 'data' using 3 t "Server", '' using 4 t "Client", '' using 5:xtic(1) t "Network"

pause -1 "Hit any key to continue"

The script above assumes that the data is stored in a file named 'data'. To run the script, put the code above in a file e.g. histo.gp, then run gnuplot as follows :

gnuplot histo.gp

The output will be in ““histo.jpeg” and would look something like this :