@@ -6324,7 +6324,8 @@ def table(self, **kwargs):
6324
6324
def hist (self , x , bins = None , range = None , density = None , weights = None ,
6325
6325
cumulative = False , bottom = None , histtype = 'bar' , align = 'mid' ,
6326
6326
orientation = 'vertical' , rwidth = None , log = False ,
6327
- color = None , label = None , stacked = False , ** kwargs ):
6327
+ color = None , label = None , stacked = False , normed = None ,
6328
+ ** kwargs ):
6328
6329
"""
6329
6330
Plot a histogram.
6330
6331
@@ -6392,26 +6393,30 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6392
6393
number of observations. If *stacked* is also ``True``, the sum of
6393
6394
the histograms is normalized to 1.
6394
6395
6395
- Default is ``False``.
6396
+ Default is ``None`` for both *normed* and *density*. If either is
6397
+ set, then that value will be used. If neither are set, then the
6398
+ args will be treated as ``False``.
6399
+
6400
+ If both *density* and *normed* are set an error is raised.
6396
6401
6397
6402
weights : (n, ) array_like or None, optional
6398
- An array of weights, of the same shape as *x*. Each value in
6399
- *x* only contributes its associated weight towards the bin count
6400
- (instead of 1). If *density* is ``True``, the weights are
6401
- normalized, so that the integral of the density over the range
6402
- remains 1.
6403
+ An array of weights, of the same shape as *x*. Each value in *x*
6404
+ only contributes its associated weight towards the bin count
6405
+ (instead of 1). If *normed* or * density* is ``True``,
6406
+ the weights are normalized, so that the integral of the density
6407
+ over the range remains 1.
6403
6408
6404
6409
Default is ``None``
6405
6410
6406
6411
cumulative : bool, optional
6407
- If ``True``, then a histogram is computed where each bin gives
6408
- the counts in that bin plus all bins for smaller values. The last
6409
- bin gives the total number of datapoints. If *density* is also
6410
- ``True`` then the histogram is normalized such that the last bin
6411
- equals 1. If *cumulative* evaluates to less than 0 (e.g., -1), the
6412
- direction of accumulation is reversed. In this case, if *density*
6413
- is also ``True``, then the histogram is normalized such that the
6414
- first bin equals 1.
6412
+ If ``True``, then a histogram is computed where each bin gives the
6413
+ counts in that bin plus all bins for smaller values. The last bin
6414
+ gives the total number of datapoints. If *normed* or *density*
6415
+ is also ``True`` then the histogram is normalized such that the
6416
+ last bin equals 1. If *cumulative* evaluates to less than 0
6417
+ (e.g., -1), the direction of accumulation is reversed.
6418
+ In this case, if *normed* and/or *density* is also ``True``, then
6419
+ the histogram is normalized such that the first bin equals 1.
6415
6420
6416
6421
Default is ``False``
6417
6422
@@ -6491,15 +6496,19 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6491
6496
6492
6497
Default is ``False``
6493
6498
6499
+ normed : bool, optional
6500
+ Deprecated; use the density keyword argument instead.
6501
+
6494
6502
Returns
6495
6503
-------
6496
6504
n : array or list of arrays
6497
- The values of the histogram bins. See *density* and *weights* for a
6498
- description of the possible semantics. If input *x* is an array,
6499
- then this is an array of length *nbins*. If input is a sequence of
6500
- arrays ``[data1, data2,..]``, then this is a list of arrays with
6501
- the values of the histograms for each of the arrays in the same
6502
- order.
6505
+ The values of the histogram bins. See *normed* or *density*
6506
+ and *weights* for a description of the possible semantics.
6507
+ If input *x* is an array, then this is an array of length
6508
+ *nbins*. If input is a sequence of arrays
6509
+ ``[data1, data2,..]``, then this is a list of arrays with
6510
+ the values of the histograms for each of the arrays in the
6511
+ same order.
6503
6512
6504
6513
bins : array
6505
6514
The edges of the bins. Length nbins + 1 (nbins left edges and right
@@ -6548,6 +6557,15 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6548
6557
if histtype == 'barstacked' and not stacked :
6549
6558
stacked = True
6550
6559
6560
+ if density is not None and normed is not None :
6561
+ raise ValueError ("kwargs 'density' and 'normed' cannot be used "
6562
+ "simultaneously. "
6563
+ "Please only use 'density', since 'normed'"
6564
+ "is deprecated." )
6565
+ if normed is not None :
6566
+ cbook .warn_deprecated ("2.1" , name = "'normed'" , obj_type = "kwarg" ,
6567
+ alternative = "'density'" , removal = "3.1" )
6568
+
6551
6569
# basic input validation
6552
6570
input_empty = np .size (x ) == 0
6553
6571
# Massage 'x' for processing.
@@ -6603,6 +6621,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6603
6621
xmin = min (xmin , np .nanmin (xi ))
6604
6622
xmax = max (xmax , np .nanmax (xi ))
6605
6623
bin_range = (xmin , xmax )
6624
+ density = bool (density ) or bool (normed )
6606
6625
if density and not stacked :
6607
6626
hist_kwargs = dict (range = bin_range , density = density )
6608
6627
else :
0 commit comments