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

Skip to content

Commit 420edf8

Browse files
committed
Fix incorrect converter used for horizontal histograms.
1 parent 762c767 commit 420edf8

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
@@ -6470,18 +6470,23 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
64706470
x = cbook._reshape_2D(x, 'x')
64716471
nx = len(x) # number of datasets
64726472

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

64806485
if bin_range is not None:
6481-
bin_range = self.convert_xunits(bin_range)
6486+
bin_range = convert_units(bin_range)
64826487

64836488
if not cbook.is_scalar_or_string(bins):
6484-
bins = self.convert_xunits(bins)
6489+
bins = convert_units(bins)
64856490

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

0 commit comments

Comments
 (0)