On Thu, Jul 12, 2012 at 1:58 PM, Daπid <davidmenhur@...> wrote:
> I don't know if there is any reason for not having it, but as a
> workaround, you could use np.hist to get the data (syntax is the same
> as mpl.hist and returns the same numbers, but without drawing) and
> then renormalise and plot with mpl.bars.
>
> On Thu, Jul 12, 2012 at 4:42 PM, Alan G Isaac <alan.isaac@...>
> wrote:
> > This is essentially a query about why certain histogram types
> > are not offered. I can see two possible answers: haven't gotten
> > to them, or, don't want to offer them (e.g., they're bad practice).
> >
> > I will choose Stata as a point of comparison.
> > http://www.stata.com/help.cgi?hist
> > The types are density, fraction, frequency, and percent.
> > Frequency corresponds of mpl's normed=False.
> > Density corresponds of mpl's normed=True.
> > Today I wanted the 'fraction' type, but mpl did not offer it.
> > (Note that because of other elements of the graph, hacks like
> > replacing the ticklabels won't work nicely.)
> >
> > If there is not sentiment against offering these types,
> > I suggest that the `normed` keyword accept strings,
> > including "fraction" and "percent", and that `hist`
> > be extended to produce these types.
> >
> > Cheers,
> > Alan Isaac
> >
>
Alan,
It is tricky to balance functionality, conciseness, and usability. It is
both a shortcoming and a strength that we strive to provide a nofrills
library that gives the user plenty of rope, while still trying to
anticipate most users' needs so that they can get stuff prototyped and
working. For most other plots, one would simply convert the data units
themselves prior to plotting. However, hist() is a different beast from
say, plot() or scatter(), because hist() inherently performs calculations
upon the input data and displays the results of those calculations.
Therefore, one can't simply perform a conversion on the data prior to
calling hist() like one would for other functions.
In that light, your idea makes a lot of sense and could essentially be
considered as a way to "pretty print" what the graph would normally look
like if normed=True. In other words, having normed='percent' would
essentially perform the calculations exactly as it would if normed=True,
but would multiply the ycoordinate system by 100. Is that what you are
looking for?
Cheers!
Ben Root
