8000 Add notes about accepting masked arrays to hist · matplotlib/matplotlib@d9c49aa · GitHub
[go: up one dir, main page]

Skip to content

Commit d9c49aa

Browse filesBrowse files
committed
Add notes about accepting masked arrays to hist
1 parent 08fbc97 commit d9c49aa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

doc/users/next_whats_new/2017-11-09_hist-ignores-nans.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ Histogram function now accepts nan values in input
44
The `~.Axes.hist` function now accepts nan values in both the *data* and
55
*weights* input. Previously this would just error. Now any invalid values
66
are simply ignored when calculating the histogram values.
7+
8+
In addition, masked arrays are now valid input for both *data* and *weights*.

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5880,7 +5880,9 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
58805880
----------
58815881
x : (n,) array or sequence of (n,) arrays
58825882
Input values, this takes either a single array or a sequence of
5883-
arrays which are not required to be of the same length
5883+
arrays which are not required to be of the same length.
5884+
Masked arrays or arrays with invalid values (e.g. ``nan``) are
5885+
allowed.
58845886
58855887
bins : integer or sequence or 'auto', optional
58865888
If an integer is gi 722D ven, ``bins + 1`` bin edges are calculated and
@@ -5936,7 +5938,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
59365938
only contributes its associated weight towards the bin count
59375939
(instead of 1). If *normed* or *density* is ``True``,
59385940
the weights are normalized, so that the integral of the density
5939-
over the range remains 1.
5941+
over the range remains 1. Masked arrays or arrays with invalid
5942+
values (e.g. ``nan``) are allowed.
59405943
59415944
Default is ``None``
59425945

0 commit comments

Comments
 (0)
0