@@ -5879,7 +5879,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
58795879 Parameters
58805880 ----------
58815881 x : (n,) array or sequence of (n,) arrays
5882- Input values, this takes either a single array or a sequency of
5882+ Input values, this takes either a single array or a sequence of
58835883 arrays which are not required to be of the same length
58845884
58855885 bins : integer or sequence or 'auto', optional
@@ -6091,30 +6091,36 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
60916091 "Please only use 'density', since 'normed'"
60926092 "will be deprecated." )
60936093
6094- # process the unit information
6095- self ._process_unit_info (xdata = x , kwargs = kwargs )
6096- x = self .convert_xunits (x )
6097- if bin_range is not None :
6098- bin_range = self .convert_xunits (bin_range )
6099-
6100- # Check whether bins or range are given explicitly.
6101- binsgiven = (cbook .iterable (bins ) or bin_range is not None )
6102-
61036094 # basic input validation
61046095 input_empty = np .size (x ) == 0
6105-
61066096 # Massage 'x' for processing.
61076097 if input_empty :
61086098 x = np .array ([[]])
61096099 else :
61106100 x = cbook ._reshape_2D (x , 'x' )
61116101 nx = len (x ) # number of datasets
61126102
6103+ # Process unit information
6104+ # If doing a stacked histogram, the input is a list of datasets, so
6105+ # we need to do the unit conversion individually on each dataset
6106+ if stacked :
6107+ self ._process_unit_info (xdata = x [0 ], kwargs = kwargs )
6108+ x = [self .convert_xunits (xi ) for xi in x ]
6109+ else :
6110+ self ._process_unit_info (xdata = x , kwargs = kwargs )
6111+ x = self .convert_xunits (x )
6112+
6113+ if bin_range is not None :
6114+ bin_range = self .convert_xunits (bin_range )
6115+
6116+ # Check whether bins or range are given explicitly.
6117+ binsgiven = (cbook .iterable (bins ) or bin_range is not None )
6118+
61136119 # We need to do to 'weights' what was done to 'x'
61146120 if weights is not None :
61156121 w = cbook ._reshape_2D (weights , 'weights' )
61166122 else :
6117- w = [None ]* nx
6123+ w = [None ] * nx
61186124
61196125 if len (w ) != nx :
61206126 raise ValueError ('weights should have the same shape as x' )
0 commit comments