weighted histograms

So, I guess the question is does anyone know any neat tricks

    > to get this to work?

Ask you friendly neighborhood developer to support this in the hist
signature?

There are a few ways to go here.

1) hist takes an option kwarg n=None which is len(bins) and gives the
   counts. If n is not None, use it rather than calling mlab.hist.
   In this case, the user would be obliged to pass bins as a sequence
   rather than an int. If n is None, call mlab.hist

2) hist takes an optional kwarg func=None. If func is None use
   mlab.hist, otherwise call n,bins = func(x, bins, normed); ie func
   has the same signature as mlab.hist.

3) matplotlib.axes.Axes.hist (which the matlab interface function
   wraps) is just a 5 line function, and one of those lines is calling
   mlab.hist - take a look at the src code in axes.py. Once you have
   your n, bins from your custom function, you can call bar, just as
   hist does. Ie it's so easy to plot a histogram using bar that you
   may not need to bother with altering the matplotlib.matlab hist.

I'm happy with any of these. Suggestions welcome.

JDH

I personally vote for this option. I had a similar need just a couple
of days ago, namely creating a summed histogram from a number of
repeated simulations, and I just did the sums myself and called bar. It
is probably best to keep matplotlib.matlab hist clean and simple.

Steve Walton

···

On Tue, 2004-09-28 at 18:52, John Hunter wrote:

Once you have
   your n, bins from your custom function, you can call bar, just as
   hist does. Ie it's so easy to plot a histogram using bar that you
   may not need to bother with altering the matplotlib.matlab hist.