On Fri, Oct 22, 2010 at 11:31 AM, Maarten Sneep <maarten.sn...@knmi.nl> wrote:
> On Fri, 2010-10-22 at 11:12 -0500, Ryan May wrote:
>> On Fri, Oct 22, 2010 at 9:40 AM, Christopher Fonnesbeck
>>
>> > If there are only 7 possible values of the data, which are
>> evenly-spaced, it should probably not go in and create more than 6
>> bins as the default behavior. I know I can specify bins by hand, but
>> when automated it would be nice to have a more sensible default.
>>
>> It just defaults to creating 10 bins (which is identical to
>> numpy.histogram, which is what does the work under the hood.) If you
>> know how many bins you want, you can just do:
>>
>> hist(x, bins=6)
>>
>> This gives (for your example) the behavior you seem to want.  I don't
>> know of any way that would sensibly choose a number of bins
>> automatically, but I'd consider a patch that proves me wrong. :)
>
> I'm moving on from IDL. From that background I used the Coyote library
> quite a bit, and there I found:
>
>   binsize = (3.5 * numpy.std(data)) / len(data)**(0.3333)
>
> (from http://www.dfanning.com/programs/histoplot.pro known as Scott's
> Choice of bin size for histograms).

Thanks for that. This actually led me here:
http://en.wikipedia.org/wiki/Histogram which gives a bunch of
different ways to estimate the number of bins/binsize. It might be
worth looking at one of these in general. However, ironically enough,
these wouldn't actually give the original poster the desired
results--the binsizes would lead to lots of bins, many of which would
be empty due to the integer data. In fact, it seems that all of these
methods are going to break down due to integer data. I guess you could
take the ceiling of the calculated binsize...anyone have an opinion on
whether calculating binsize/nbins would be a step forward over leaving
the default (of 10) and letting the user calculate if they like?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to