Sunday, November 11, 2012

Gnuplot: how to draw histograms, the easy way

Suppose the test data is like


Num_clients S1 S2 S3 S4
1 6.853 6.812 6.811 6.813
2 10.726 10.701 10.699 10.7
3 15.122 15.101 15.099 15.1
4 21.761 21.699 21.695 21.696
5 28.254 28.231 28.233 28.232


We can plot a clustered histogram graph with the gnuplot script:

set terminal postscript eps enhanced 
set output 'test.eps'
set size 0.6,0.6
set yrange [1:50]
set xlabel "Num Mobile Clients (x10^5)"
set ylabel 'Server Workload (s)'

set xtics border nomirror
set ytics border nomirror

set style fill pattern
set style data histogram
set style histogram clustered gap 1

plot 'test.dat' u 2:xtic(1) title columnheader, \
'' u 3:xtic(1) title columnheader, \
'' u 4:xtic(1) title columnheader, \
'' u 5:xtic(1) title columnheader fs pattern 6



No comments:

Post a Comment