Say I have a single column of sorted numbers (given
3 3 4 4 4 5 6 6 8
and want to plot a histogram, something like:
| = = =
| = = = = =
0 1 2 3 4 5 6 7 8
In order to get the data into a suitable state for
plotting with 'histogram', do I have to fill the bins
myself, or can 'gnuplot' do that for me?
If this is not supported, would it be a useful
addition? The case above is integer-valued and the bin
width is intuitively one. More complicated
integer-valued data and continuous data would need the
used to define the bin width, I suppose.
I couldn't see anything in the PDF documentation or in
any suggestions gratefully received, Robbie
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
University email (redirected) : morrison@...
Webmail (preferred) : robbie@...
[from Webmail client]
not, this is not possible, at least not without making your life very
difficult. Gnuplot is not and never was meant to be a calculation tool,
that's what OOCalc and Excel are for.
Besides, you will always have to adjust your data carefully, especially in
scientific applications, i. e. when trying to fit a distribution function to
your data or choosing the binning size. Even Excel only uses the sqrt(n)
rule although more sophisticade approaches are available:
I suggest using the COUNTIF functions of the above mentioned spreadsheet
View this message in context: http://old.nabble.com/automatic-binning-for-histogram-tp32038612p32052193.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
On 11 Jul 2011, at 16:42, Robbie Morrison wrote:
> Say I have a single column of sorted numbers (given
> here horizontally):
> 3 3 4 4 4 5 6 6 8
> and want to plot a histogram, something like:
> | =
> | = = =
> | = = = = =
> 0 1 2 3 4 5 6 7 8
> In order to get the data into a suitable state for
> plotting with 'histogram', do I have to fill the bins
> myself, or can 'gnuplot' do that for me?
You could try this to start with. It assumes you have your raw data in a single-column file called foo.dat.
set boxwidth 1
bw = 1
bin(x,width)=width*floor(x/width) + bw/2.0
set xrange [0:*]
set yrange [0:*]
plot 'foo.dat' using (bin($1,bw)):(1.0) smooth freq with boxes