Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98ebd9d

Browse files
committed
Fix incorrect converter used for horizontal histograms.
1 parent 7512f67 commit 98ebd9d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6464,18 +6464,23 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
64646464
x = cbook._reshape_2D(x, 'x')
64656465
nx = len(x) # number of datasets
64666466

6467-
# Process unit information
6468-
# Unit conversion is done individually on each dataset
6469-
self._process_unit_info(
6470-
{"x" if orientation == "vertical" else "y": x[0]}, kwargs,
6471-
convert=False)
6472-
x = [self.convert_xunits(xi) for xi in x]
6467+
# Process unit information. _process_unit_info sets the unit and
6468+
# converts the first dataset; then we convert each following dataset
6469+
# one at a time.
6470+
if orientation == "vertical":
6471+
convert_units = self.convert_yunits
6472+
x = [*self._process_unit_info({"x": x[0]}, kwargs),
6473+
*map(convert_units, x[1:])]
6474+
else: # horizontal
6475+
convert_units = self.convert_yunits
6476+
x = [*self._process_unit_info({"y": x[0]}, kwargs),
6477+
*map(convert_units, x[1:])]
64736478

64746479
if bin_range is not None:
6475-
bin_range = self.convert_xunits(bin_range)
6480+
bin_range = convert_units(bin_range)
64766481

64776482
if not cbook.is_scalar_or_string(bins):
6478-
bins = self.convert_xunits(bins)
6483+
bins = convert_units(bins)
64796484

64806485
# We need to do to 'weights' what was done to 'x'
64816486
if weights is not None:

0 commit comments

Comments
 (0)