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

Skip to content

Commit c4b9364

Browse files
committed
Add notes about accepting masked arrays to hist
1 parent d5a0eb9 commit c4b9364

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
@@ -5893,7 +5893,9 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
58935893
----------
58945894
x : (n,) array or sequence of (n,) arrays
58955895
Input values, this takes either a single array or a sequence of
5896-
arrays which are not required to be of the same length
5896+
arrays which are not required to be of the same length.
5897+
Masked arrays or arrays with invalid values (e.g. ``nan``) are
5898+
allowed.
58975899
58985900
bins : integer or sequence or 'auto', optional
58995901
If an integer is given, ``bins + 1`` bin edges are calculated and
@@ -5949,7 +5951,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
59495951
only contributes its associated weight towards the bin count
59505952
(instead of 1). If *normed* or *density* is ``True``,
59515953
the weights are normalized, so that the integral of the density
5952-
over the range remains 1.
5954+
over the range remains 1. Masked arrays or arrays with invalid
5955+
values (e.g. ``nan``) are allowed.
59535956
59545957
Default is ``None``
59555958

0 commit comments

Comments
 (0)
0