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

Skip to content

Correctly convert units for a stacked histogram#9654

Merged
efiring merged 3 commits into
matplotlib:masterfrom
dstansby:stacked-datetime
Nov 14, 2017
Merged

Correctly convert units for a stacked histogram#9654
efiring merged 3 commits into
matplotlib:masterfrom
dstansby:stacked-datetime

Conversation

@dstansby
Copy link
Copy Markdown
Member

@dstansby dstansby commented Nov 1, 2017

Fixes #5898. Hopefully the comment I've added in the code should make it clear what's going on.

Comment thread 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))
Copy link
Copy Markdown
Contributor

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] ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ thanks...

Comment thread lib/matplotlib/axes/_axes.py Outdated

# 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each

@dstansby dstansby added this to the v2.2 milestone Nov 4, 2017
Copy link
Copy Markdown
Member

@efiring efiring left a 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.

Comment thread 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]
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Member

@efiring efiring left a 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.

Comment thread lib/matplotlib/axes/_axes.py Outdated
# Massage 'x' for processing.
if input_empty:
x = np.array([[]])
x = [np.array([[]])]
Copy link
Copy Markdown
Member

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.

@efiring efiring merged commit 905465b into matplotlib:master Nov 14, 2017
@dstansby dstansby deleted the stacked-datetime branch November 14, 2017 19:53
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants