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

Skip to content

Commit db696a4

Browse files
committed
Fix incorrect converter used for horizontal histograms.
1 parent b543bc0 commit db696a4

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

6595-
# Process unit information
6596-
# Unit conversion is done individually on each dataset
6597-
self._process_unit_info(
6598-
{"x" if orientation == "vertical" else "y": x[0]}, kwargs,
6599-
convert=False)
6600-
x = [self.convert_xunits(xi) for xi in x]
6595+
# Process unit information. _process_unit_info sets the unit and
6596+
# converts the first dataset; then we convert each following dataset
6597+
# one at a time.
6598+
if orientation == "vertical":
6599+
convert_units = self.convert_yunits
6600+
x = [*self._process_unit_info({"x": x[0]}, kwargs),
6601+
*map(convert_units, x[1:])]
6602+
else: # horizontal
6603+
convert_units = self.convert_yunits
6604+
x = [*self._process_unit_info({"y": x[0]}, kwargs),
6605+
*map(convert_units, x[1:])]
66016606

66026607
if bin_range is not None:
6603-
bin_range = self.convert_xunits(bin_range)
6608+
bin_range = convert_units(bin_range)
66046609

66056610
if not cbook.is_scalar_or_string(bins):
6606-
bins = self.convert_xunits(bins)
6611+
bins = convert_units(bins)
66076612

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

0 commit comments

Comments
 (0)