Articles

Histogramming with gnuplot

In howto on Apr 25, 2012 by theoryl Tagged: , ,

I just learned this gnuplot trick from http://stackoverflow.com/questions/2471884/histogram-using-gnuplot and http://gnuplot-surprising.blogspot.com/2011/09/statistic-analysis-and-histogram.html.

I tweaked it a bit:
nbins=100
min=0.
max=1.
width=(max-min)/nbins
hist(x,width)=width*floor(x/width)+width/2.0
set boxwidth width
#set style fill solid 0.5
set xtics min,(max-min)/5,max
set tics out nomirror
set xlabel "x"
set ylabel "Event"

plot[min:max] "rawdata.dat" u (hist($1,width)):(1.0) smooth freq w histeps lc rgb "blue" notitle

Leave a comment