Revision: 8317 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8317&view=rev Author: efiring Date: 2010-05-17 19:03:58 +0000 (Mon, 17 May 2010)
Log Message: ----------- Axes.hist: fix bug in handling of weights kwarg; thanks to Jeff Klukas. Also use weights kwarg in examples/histogram_demo_extended. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2010-05-13 09:13:49 UTC (rev 8316) +++ trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2010-05-17 19:03:58 UTC (rev 8317) @@ -1,4 +1,5 @@ #!/usr/bin/env python +import numpy as np import pylab as P # @@ -90,8 +91,20 @@ x1 = mu + sigma*P.randn(7000) x2 = mu + sigma*P.randn(3000) +# and exercise the weights option by arbitrarily giving the first half +# of each series only half the weight of the others: + +w0 = np.ones_like(x0) +w0[:len(x0)/2] = 0.5 +w1 = np.ones_like(x1) +w1[:len(x1)/2] = 0.5 +w2 = np.ones_like(x2) +w0[:len(x2)/2] = 0.5 + + + P.figure() -n, bins, patches = P.hist( [x0,x1,x2], 10, histtype='bar') +n, bins, patches = P.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar') P.show() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2010-05-13 09:13:49 UTC (rev 8316) +++ trunk/matplotlib/lib/matplotlib/axes.py 2010-05-17 19:03:58 UTC (rev 8317) @@ -7364,7 +7364,7 @@ raise ValueError("color kwarg must have one color per dataset") if weights is not None: - if isinstance(w, np.ndarray): + if isinstance(weights, np.ndarray): w = np.array(weights) if w.ndim == 2: w = w.T This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins