Hi,

I attach a trivial patch to pass a weight argument through hist() to histogram().

Cheers,
Olle
--- axes.py	(revision 6329)
+++ axes.py	(working copy)
@@ -6221,13 +6221,13 @@
 
     def hist(self, x, bins=10, range=None, normed=False, cumulative=False,
              bottom=None, histtype='bar', align='mid',
-             orientation='vertical', rwidth=None, log=False, **kwargs):
+             orientation='vertical', rwidth=None, log=False, weights=None, **kwargs):
         """
         call signature::
 
           hist(x, bins=10, range=None, normed=False, cumulative=False,
                bottom=None, histtype='bar', align='mid',
-               orientation='vertical', rwidth=None, log=False, **kwargs)
+               orientation='vertical', rwidth=None, log=False, weights=None, **kwargs)
 
         Compute the histogram of *x*. The return value is a tuple
         (*n*, *bins*, *patches*) or ([*n0*, *n1*, ...], *bins*,
@@ -6311,6 +6311,13 @@
             be filtered out and only the non-empty (*n*, *bins*,
             *patches*) will be returned.
 
+          *weights*: array
+            An array of weights, the same shape as x. If normed is False,
+            the histogram is computed by summing the weights of the values
+            falling into each bin. If normed is True, the weights are
+            normalized, so that the integral of the density over the range
+            is 1.
+
         kwargs are used to update the properties of the hist
         :class:`~matplotlib.patches.Rectangle` instances:
 
@@ -6355,7 +6362,7 @@
             # this will automatically overwrite bins,
             # so that each histogram uses the same bins
             m, bins = np.histogram(x[i], bins, range=range,
-                normed=bool(normed), new=True)
+                normed=bool(normed), weights=weights, new=True)
             n.append(m)
 
         if cumulative:
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to