Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f076d56

Browse files
committed
Fix inconsistency with the handling of the 'weights' keyword and input data for hist().
svn path=/branches/v1_0_maint/; revision=8595
1 parent baccce3 commit f076d56

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/axes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7551,6 +7551,8 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
75517551
'hist now uses the rwidth to give relative width '
75527552
'and not absolute width')
75537553

7554+
# Massage 'x' for processing.
7555+
# NOTE: Be sure any changes here is also done below to 'weights'
75547556
if isinstance(x, np.ndarray) or not iterable(x[0]):
75557557
# TODO: support masked arrays;
75567558
x = np.asarray(x)
@@ -7577,8 +7579,9 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
75777579
if len(color) != nx:
75787580
raise ValueError("color kwarg must have one color per dataset")
75797581

7582+
# We need to do to 'weights' what was done to 'x'
75807583
if weights is not None:
7581-
if isinstance(weights, np.ndarray):
7584+
if isinstance(weights, np.ndarray) or not iterable(weights[0]) :
75827585
w = np.array(weights)
75837586
if w.ndim == 2:
75847587
w = w.T

0 commit comments

Comments
 (0)