@@ -5879,7 +5879,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
5879
5879
Parameters
5880
5880
----------
5881
5881
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
5883
5883
arrays which are not required to be of the same length
5884
5884
5885
5885
bins : integer or sequence or 'auto', optional
@@ -6091,30 +6091,36 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6091
6091
"Please only use 'density', since 'normed'"
6092
6092
"will be deprecated." )
6093
6093
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
-
6103
6094
# basic input validation
6104
6095
input_empty = np .size (x ) == 0
6105
-
6106
6096
# Massage 'x' for processing.
6107
6097
if input_empty :
6108
6098
x = np .array ([[]])
6109
6099
else :
6110
6100
x = cbook ._reshape_2D (x , 'x' )
6111
6101
nx = len (x ) # number of datasets
6112
6102
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
+
6113
6119
# We need to do to 'weights' what was done to 'x'
6114
6120
if weights is not None :
6115
6121
w = cbook ._reshape_2D (weights , 'weights' )
6116
6122
else :
6117
- w = [None ]* nx
6123
+ w = [None ] * nx
6118
6124
6119
6125
if len (w ) != nx :
6120
6126
raise ValueError ('weights should have the same shape as x' )
0 commit comments