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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: