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

Skip to content

Commit 4855c75

Browse files
committed
Update hist() docstring following removal of normed kwarg.
and change the default of density from None to False. (This doesn't change anything from the API PoV as we convert the kwarg using `bool` anyways, but the default was previously `None` for the sole purpose of detecting when both `normed` and `density` were both passed and error out in that case.)
1 parent b1ae81c commit 4855c75

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6324,7 +6324,7 @@ def clabel(self, CS, *args, **kwargs):
63246324
#### Data analysis
63256325

63266326
@_preprocess_data(replace_names=["x", 'weights'], label_namer="x")
6327-
def hist(self, x, bins=None, range=None, density=None, weights=None,
6327+
def hist(self, x, bins=None, range=None, density=False, weights=None,
63286328
cumulative=False, bottom=None, histtype='bar', align='mid',
63296329
orientation='vertical', rwidth=None, log=False,
63306330
color=None, label=None, stacked=False, **kwargs):
@@ -6396,11 +6396,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
63966396
number of observations. If *stacked* is also ``True``, the sum of
63976397
the histograms is normalized to 1.
63986398
6399-
Default is ``None`` for both *normed* and *density*. If either is
6400-
set, then that value will be used. If neither are set, then the
6401-
args will be treated as ``False``.
6402-
6403-
If both *density* and *normed* are set an error is raised.
6399+
Default is ``False``.
64046400
64056401
weights : (n, ) array_like or None, optional
64066402
An array of weights, of the same shape as *x*. Each value in *x*
@@ -6420,15 +6416,18 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64206416
64216417
(or you may alternatively use `~.bar()`).
64226418
6423-
cumulative : bool, optional
6419+
cumulative : bool or -1, optional
64246420
If ``True``, then a histogram is computed where each bin gives the
64256421
counts in that bin plus all bins for smaller values. The last bin
6426-
gives the total number of datapoints. If *normed* or *density*
6427-
is also ``True`` then the histogram is normalized such that the
6428-
last bin equals 1. If *cumulative* evaluates to less than 0
6429-
(e.g., -1), the direction of accumulation is reversed.
6430-
In this case, if *normed* and/or *density* is also ``True``, then
6431-
the histogram is normalized such that the first bin equals 1.
6422+
gives the total number of datapoints.
6423+
6424+
If *density* is also ``True`` then the histogram is normalized such
6425+
that the last bin equals 1.
6426+
6427+
If *cumulative* is a number less than 0 (e.g., -1), the direction
6428+
of accumulation is reversed. In this case, if *density* is also
6429+
``True``, then the histogram is normalized such that the first bin
6430+
equals 1.
64326431
64336432
Default is ``False``
64346433
@@ -6445,26 +6444,19 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64456444
64466445
- 'bar' is a traditional bar-type histogram. If multiple data
64476446
are given the bars are arranged side by side.
6448-
64496447
- 'barstacked' is a bar-type histogram where multiple
64506448
data are stacked on top of each other.
6451-
6452-
- 'step' generates a lineplot that is by default
6453-
unfilled.
6454-
6455-
- 'stepfilled' generates a lineplot that is by default
6456-
filled.
6449+
- 'step' generates a lineplot that is by default unfilled.
6450+
- 'stepfilled' generates a lineplot that is by default filled.
64576451
64586452
Default is 'bar'
64596453
64606454
align : {'left', 'mid', 'right'}, optional
64616455
Controls how the histogram is plotted.
64626456
6463-
- 'left': bars are centered on the left bin edges.
6464-
6465-
- 'mid': bars are centered between the bin edges.
6466-
6467-
- 'right': bars are centered on the right bin edges.
6457+
- 'left': bars are centered on the left bin edges.
6458+
- 'mid': bars are centered between the bin edges.
6459+
- 'right': bars are centered on the right bin edges.
64686460
64696461
Default is 'mid'
64706462

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2633,7 +2633,7 @@ def hexbin(
26332633
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
26342634
@docstring.copy(Axes.hist)
26352635
def hist(
2636-
x, bins=None, range=None, density=None, weights=None,
2636+
x, bins=None, range=None, density=False, weights=None,
26372637
cumulative=False, bottom=None, histtype='bar', align='mid',
26382638
orientation='vertical', rwidth=None, log=False, color=None,
26392639
label=None, stacked=False, *, data=None, **kwargs):

0 commit comments

Comments
 (0)