Skip to content
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

VIS: Fix DataFrame.plot() produces incorrect legend markers when plotting multiple series on the same axis #27808

Merged
merged 22 commits into from
Aug 16, 2019

Conversation

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented Aug 7, 2019

I found out that the reason this happens is because subplots is not updated accordingly when plt.subplots() is used and assign to ax, e.g. fig, ax = plt.subplots(nrows=1, ncols=3). I tested my solution and things all get solved, and figure looks very correct like below:
Screen Shot 2019-08-07 at 10 03 39 PM

BTW, i am not very sure how to properly test this, and would be nice to know!

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

A test would be nice. Does the issue post have one?

pandas/plotting/_matplotlib/core.py Outdated Show resolved Hide resolved
pandas/plotting/_matplotlib/core.py Outdated Show resolved Hide resolved
@charlesdong1991
Copy link
Member Author

charlesdong1991 commented Aug 7, 2019

@TomAugspurger thanks very much for your quick review! Just curious about what you mean by Does the issue post have one? this issue does provide a fail case, but no test is given.
I do see some tests for plotting, but since this issue is mainly about missing markers in legend, i haven't found a proper solution to test if this marker/color is printed correctly. Would be very nice if you could give some hint! ^^

@charlesdong1991 charlesdong1991 changed the title VIS: Fix DataFrame.plot() produces incorrect legend labels when plotting multiple series on the same axis VIS: Fix DataFrame.plot() produces incorrect legend markers when plotting multiple series on the same axis Aug 7, 2019
@TomAugspurger TomAugspurger added the Visualization plotting label Aug 7, 2019
@TomAugspurger TomAugspurger added this to the 1.0 milestone Aug 7, 2019
@TomAugspurger
Copy link
Contributor

TomAugspurger commented Aug 7, 2019 via email

@charlesdong1991
Copy link
Member Author

Thanks for your quick reply, I will check it up @TomAugspurger

@pep8speaks
Copy link

pep8speaks commented Aug 8, 2019

Hello @charlesdong1991! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-14 20:47:39 UTC

@charlesdong1991 charlesdong1991 changed the title VIS: Fix DataFrame.plot() produces incorrect legend markers when plotting multiple series on the same axis [WIP] VIS: Fix DataFrame.plot() produces incorrect legend markers when plotting multiple series on the same axis Aug 8, 2019
@charlesdong1991 charlesdong1991 changed the title [WIP] VIS: Fix DataFrame.plot() produces incorrect legend markers when plotting multiple series on the same axis VIS: Fix DataFrame.plot() produces incorrect legend markers when plotting multiple series on the same axis Aug 8, 2019
@charlesdong1991
Copy link
Member Author

This is kind of new working solution with a test case that is passing all tests on my local computer, not sure if it can also pass all tests here. But in the meantime pls feel free to take a look and provide reviews if you have some time. @TomAugspurger

@charlesdong1991
Copy link
Member Author

any follow-up reviews? all are much appreciated! ^^

@TomAugspurger
Copy link
Contributor

Looks good. I'll restart the windows azure CI failure.

@charlesdong1991
Copy link
Member Author

ping

@TomAugspurger TomAugspurger merged commit 5d3b492 into pandas-dev:master Aug 16, 2019
@TomAugspurger
Copy link
Contributor

Thanks!

@comready
Copy link

If you need another example of this problem let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame.plot() produces incorrect legend labels when plotting multiple series on the same axis
4 participants