views:

3452

answers:

2

I know how to create a histogram (just use "with boxes") in gnuplot if my .dat file already has properly binned data. Is there a way to take a list of numbers and have gnuplot provide a histogram based on ranges and bin sizes the user provides?

+8  A: 

yes, and its quick and simple though very hidden:

binwidth=5
bin(x,width)=width*floor(x/width)

plot 'datafile' using (bin($1,binwidth)):(1.0) smooth freq with boxes

check out help smooth freq to see why the above makes a histogram

to deal with ranges just set the xrange variable.

Cheers /B2S

Born2Smile
+2  A: 
mas90
Actually that second part should be `bin(x,width)=width*floor(x/width) + binwidth/2.0` (floating point calculations)
PiPeep