-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Correctly convert units for a stacked histogram #9654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/matplotlib/axes/_axes.py
Outdated
self._process_unit_info(xdata=x[0], kwargs=kwargs) | ||
newx = [] | ||
for xi in x: | ||
newx.append(self.convert_xunits(xi)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x = [self.convert_xunits(xi) for xi in x]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ thanks...
lib/matplotlib/axes/_axes.py
Outdated
# Massage 'x' for processing. | ||
if input_empty: | ||
x = np.array([[]]) | ||
else: | ||
x = cbook._reshape_2D(x, 'x') | ||
nx = len(x) # number of datasets | ||
|
||
# Process unit information | ||
# If doing a stacked histogram, the input is a list of datasets, so | ||
# we need to do the unit conversion individually on eaach dataset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each
f66d5c5
to
a09798e
Compare
a09798e
to
c02a84d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something, but it looks like this is not handling all the cases it should.
lib/matplotlib/axes/_axes.py
Outdated
# we need to do the unit conversion individually on each dataset | ||
if stacked: | ||
self._process_unit_info(xdata=x[0], kwargs=kwargs) | ||
x = [self.convert_xunits(xi) for xi in x] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand: it seems to me that the criterion for needing this step is not whether the histogram is stacked, but whether x
is a list of datasets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, I'll change this and add a test for multiple datasets that aren't stacked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think I see one more detail.
lib/matplotlib/axes/_axes.py
Outdated
# Massage 'x' for processing. | ||
if input_empty: | ||
x = np.array([[]]) | ||
x = [np.array([[]])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many square brackets--I think this should be a list with one empty 1-D array, not with an empty 2-D array.
Fixes #5898. Hopefully the comment I've added in the code should make it clear what's going on.