8000 Remove some remnants of hist{,2d}(normed=...). · matplotlib/matplotlib@c16748f · GitHub
[go: up one dir, main page]

Skip to content

Commit c16748f

Browse files
committed
Remove some remnants of hist{,2d}(normed=...).
- Remove mentions of it from docstrings, example. - np.histogram2d also supports density since np1.15 eric-wieser/numpy@081050a - Reword docs for `density` in a hopefully(?) clearer manner? In particular, few users will care about the "first element of the return tuple"; what mostly matters is what gets drawn. - Refer to hist's `density` in hist2d.
1 parent dc1f0d9 commit c16748f

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

examples/statistics/histogram_features.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
2-
=========================================================
3-
Demo of the histogram (hist) function with a few features
4-
=========================================================
2+
==============================================
3+
Some features of the histogram (hist) function
4+
==============================================
55
66
In addition to the basic histogram, this demo shows a few optional features:
77
88
* Setting the number of data bins.
9-
* The ``normed`` flag, which normalizes bin heights so that the integral of
9+
* The *density* parameter, which normalizes bin heights so that the integral of
1010
the histogram is 1. The resulting histogram is an approximation of the
1111
probability density function.
1212
* Setting the face color of the bars.

lib/matplotlib/axes/_axes.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6476,22 +6476,20 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
64766476
range of x.
64776477
64786478
density : bool, default: False
6479-
If ``True``, the first element of the return tuple will
6480-
be the raw counts per bin normalized to form a probability density
6481-
so that the area under the histogram will integrate to 1, i.e.
6482-
``np.sum(n * np.diff(bins)) == 1``. (Computed by dividing the
6483-
raw counts ``n0`` by the total number of data points and
6484-
multiplying by the bin width: ``n = n0 / sum(n0) * np.diff(bins)``)
6479+
If ``True``, draw and return a probability density: each bin
6480+
will display the bin's raw count *divided by the bin width*
6481+
(``n = n0 / sum(n0) * np.diff(bins)``), so that the area under
6482+
the histogram integrates to 1 (``np.sum(n * np.diff(bins)) == 1``).
64856483
64866484
If *stacked* is also ``True``, the sum of the histograms is
64876485
normalized to 1.
64886486
64896487
weights : (n,) array-like or None, default: None
6490-
An array of weights, of the same shape as *x*. Each value in *x*
6491-
only contributes its associated weight towards the bin count
6492-
(instead of 1). If *normed* or *density* is ``True``,
6493-
the weights are normalized, so that the integral of the density
6494-
over the range remains 1.
6488+
An array of weights, of the same shape as *x*. Each value in
6489+
*x* only contributes its associated weight towards the bin count
6490+
(instead of 1). If *density* is ``True``, the weights are
6491+
normalized, so that the integral of the density over the range
6492+
remains 1.
64956493
64966494
This parameter can be used to draw a histogram of data that has
64976495
already been binned, e.g. using `numpy.histogram` (by treating each
@@ -6916,8 +6914,8 @@ def hist2d(self, x, y, bins=10, range=None, density=False, weights=None,
69166914
considered outliers and not tallied in the histogram.
69176915
69186916
density : bool, default: False
6919-
Normalize histogram. *normed* is a deprecated synonym for this
6920-
parameter.
6917+
Normalize histogram. See the documentation for the *density*
6918+
parameter of `~.Axes.hist` for more details.
69216919
69226920
weights : array-like, shape (n, ), optional
69236921
An array of values w_i weighing each sample (x_i, y_i).
@@ -6976,7 +6974,7 @@ def hist2d(self, x, y, bins=10, range=None, density=False, weights=None,
69766974
"""
69776975

69786976
h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range,
6979-
normed=density, weights=weights)
6977+
density=density, weights=weights)
69806978

69816979
if cmin is not None:
69826980
h[h < cmin] = None

0 commit comments

Comments
 (0)
0