help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Histogram Frequency Plot with Custom Bins


From: Rob Mahurin
Subject: Re: Histogram Frequency Plot with Custom Bins
Date: Tue, 3 Aug 2010 12:17:08 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Tue, Jul 27, 2010 at 12:09:34PM -0400, Manoj Deshpande wrote:
> I am computing frequency counts under each bin, the bin list is
> dynamic, all i want to do is to display what the counts were under
> each bin. From documentation it seems like i first need to call
> hist, and then bar, ( see below). With this approach,however, the
> xrange values are automatically selected, i want a bar of frequency
> height at exactly the bin value, and not automatically selected. i
> see axis() command, which allow me to set max and min values only. i
> see xrange, which is again a range. Even if i cant fix the x axis
> values, if there is some way, where i can hover over the bar, and
> display(frequency,bin) value OR , if it prints (frequency,bin) value
> in the graph itself, it will be great.
> 
> Any suggestions ?
> 
> Thanks,
> Manoj
> 
> 
>  96     bins = [avg avg+2*stdev avg+3*stdev avg+6*stdev avg+8*stdev
> avg+9*stdev avg+10*stdev];
>  97     [frequency NN]= hist(arg0,bins)
>  98     figure(1, "visible", "off"); %append plot to pdf,no need to display
>  99     bar(NN,frequency,0.3);
>           xlabel('avg   avg+2*dev    avg+3*dev   avg+6*dev    avg+8*dev
> avg+9*dev  avg+10*dev');

If you are using the Gnuplot backend with X11 output, you can hover
your mouse over the bar and find its height.

To make labels at the tops of the bars, use something like 

        for i = 1:numel(NN)
            text(NN(i), frequency(i), num2str(frequency(i)),
                        "horizontalposition","center",
                        "verticalposition","bottom");
        endfor

though in 3.2.3 at least the "verticalposition" property doesn't
appear to do anything, bummer.

To put the bin positions on the x axis, try

        set(gca,"xtick",NN)

If you don't like the default labels, assign a cell array of strings
to the "xticklabel" property:

        set(gca,"xticklabel",{"first bin","second bin"})
        ## add more if you like

Cheers,
Rob


reply via email to

[Prev in Thread] Current Thread [Next in Thread]