@@ -6295,7 +6295,8 @@ def table(self, **kwargs):
6295
6295
def hist (self , x , bins = None , range = None , density = None , weights = None ,
6296
6296
cumulative = False , bottom = None , histtype = 'bar' , align = 'mid' ,
6297
6297
orientation = 'vertical' , rwidth = None , log = False ,
6298
- color = None , label = None , stacked = False , ** kwargs ):
6298
+ color = None , label = None , stacked = False , normed = None ,
6299
+ ** kwargs ):
6299
6300
"""
6300
6301
Plot a histogram.
6301
6302
@@ -6363,26 +6364,30 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6363
6364
number of observations. If *stacked* is also ``True``, the sum of
6364
6365
the histograms is normalized to 1.
6365
6366
6366
- Default is ``False``.
6367
+ Default is ``None`` for both *normed* and *density*. If either is
6368
+ set, then that value will be used. If neither are set, then the
6369
+ args will be treated as ``False``.
6370
+
6371
+ If both *density* and *normed* are set an error is raised.
6367
6372
6368
6373
weights : (n, ) array_like or None, optional
6369
- An array of weights, of the same shape as *x*. Each value in
6370
- *x* only contributes its associated weight towards the bin count
6371
- (instead of 1). If *density* is ``True``, the weights are
6372
- normalized, so that the integral of the density over the range
6373
- remains 1.
6374
+ An array of weights, of the same shape as *x*. Each value in *x*
6375
+ only contributes its associated weight towards the bin count
6376
+ (instead of 1). If *normed* or * density* is ``True``,
6377
+ the weights are normalized, so that the integral of the density
6378
+ over the range remains 1.
6374
6379
6375
6380
Default is ``None``
6376
6381
6377
6382
cumulative : bool, optional
6378
- If ``True``, then a histogram is computed where each bin gives
6379
- the counts in that bin plus all bins for smaller values. The last
6380
- bin gives the total number of datapoints. If *density* is also
6381
- ``True`` then the histogram is normalized such that the last bin
6382
- equals 1. If *cumulative* evaluates to less than 0 (e.g., -1), the
6383
- direction of accumulation is reversed. In this case, if *density*
6384
- is also ``True``, then the histogram is normalized such that the
6385
- first bin equals 1.
6383
+ If ``True``, then a histogram is computed where each bin gives the
6384
+ counts in that bin plus all bins for smaller values. The last bin
6385
+ gives the total number of datapoints. If *normed* or *density*
6386
+ is also ``True`` then the histogram is normalized such that the
6387
+ last bin equals 1. If *cumulative* evaluates to less than 0
6388
+ (e.g., -1), the direction of accumulation is reversed.
6389
+ In this case, if *normed* and/or *density* is also ``True``, then
6390
+ the histogram is normalized such that the first bin equals 1.
6386
6391
6387
6392
Default is ``False``
6388
6393
@@ -6462,6 +6467,9 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6462
6467
6463
6468
Default is ``False``
6464
6469
6470
+ normed : bool, optional
6471
+ Deprecated; use the density keyword argument instead.
6472
+
6465
6473
Returns
6466
6474
-------
6467
6475
n : array or list of arrays
@@ -6520,6 +6528,15 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6520
6528
if histtype == 'barstacked' and not stacked :
6521
6529
stacked = True
6522
6530
6531
+ if density is not None and normed is not None :
6532
+ raise ValueError ("kwargs 'density' and 'normed' cannot be used "
6533
+ "simultaneously. "
6534
+ "Please only use 'density', since 'normed'"
6535
+ "is deprecated." )
6536
+ if normed is not None :
6537
+ cbook .warn_deprecated ("2.1" , name = "'normed'" , obj_type = "kwarg" ,
6538
+ alternative = "'density'" , removal = "3.1" )
6539
+
6523
6540
# basic input validation
6524
6541
input_empty = np .size (x ) == 0
6525
6542
# Massage 'x' for processing.
@@ -6575,6 +6592,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6575
6592
xmin = min (xmin , np .nanmin (xi ))
6576
6593
xmax = max (xmax , np .nanmax (xi ))
6577
6594
bin_range = (xmin , xmax )
6595
+ density = bool (density ) or bool (normed )
6578
6596
if density and not stacked :
6579
6597
hist_kwargs = dict (range = bin_range , density = density )
6580
6598
else :
0 commit comments