@@ -6295,7 +6295,8 @@ def table(self, **kwargs):
62956295 def hist (self , x , bins = None , range = None , density = None , weights = None ,
62966296 cumulative = False , bottom = None , histtype = 'bar' , align = 'mid' ,
62976297 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 ):
62996300 """
63006301 Plot a histogram.
63016302
@@ -6363,26 +6364,30 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
63636364 number of observations. If *stacked* is also ``True``, the sum of
63646365 the histograms is normalized to 1.
63656366
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.
63676372
63686373 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.
63746379
63756380 Default is ``None``
63766381
63776382 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.
63866391
63876392 Default is ``False``
63886393
@@ -6462,6 +6467,9 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64626467
64636468 Default is ``False``
64646469
6470+ normed : bool, optional
6471+ Deprecated; use the density keyword argument instead.
6472+
64656473 Returns
64666474 -------
64676475 n : array or list of arrays
@@ -6520,6 +6528,15 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65206528 if histtype == 'barstacked' and not stacked :
65216529 stacked = True
65226530
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+
65236540 # basic input validation
65246541 input_empty = np .size (x ) == 0
65256542 # Massage 'x' for processing.
@@ -6575,6 +6592,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65756592 xmin = min (xmin , np .nanmin (xi ))
65766593 xmax = max (xmax , np .nanmax (xi ))
65776594 bin_range = (xmin , xmax )
6595+ density = bool (density ) or bool (normed )
65786596 if density and not stacked :
65796597 hist_kwargs = dict (range = bin_range , density = density )
65806598 else :
0 commit comments