-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Fix legend yerr #40777
Merged
Merged
Fix legend yerr #40777
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MarcoGorelli
force-pushed
the
fix-legend-yerr
branch
from
April 5, 2021 10:14
d16bc69
to
91e592a
Compare
is #39522 closed? (or partial) |
jreback
reviewed
Apr 5, 2021
@@ -0,0 +1,45 @@ | |||
import pytest | |||
|
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.
can you move other legend tests here? (if we have them)
either way |
OK, have moved those tests over in this pr @jreback |
thanks @MarcoGorelli very nice! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
secondary_y
and then plotting another line results in wrong color for (right) line #40044I spent several hours on this, and I don't think there's a simple solution at the moment (though I'd love to be proved wrong!)
Background:
in Nov 2017, #18222 was opened, in which it was noted that marker info isn't preserved in legends. This is because we were getting legend handles using
leg.legendHandles
:pandas/pandas/plotting/_matplotlib/core.py
Line 574 in b623a9d
Due to an open issue in matplotlib,
leg.legendHandles
doesn't preserve marker info. So, in #27808, the code was updated to useax.get_legend_handles_labels
:pandas/pandas/plotting/_matplotlib/core.py
Line 604 in 5d3b492
This preserves marker info but has the problem that it may contain additional objects which aren't visible in the legend. The result of this is the permutations observed in #39522 .
I think that having wrong colours in the legend, as in #39522 and #40044, is far worse than the legend not preserving marker info. Solving everything together doesn't currently seem doable, at least not until matplotlib/matplotlib#11357 is solved in matplotlib.
So my suggestion is to revert some of the changes in #27808, so that at least the colors are right, and when the matplotlib issue is addressed, then the marker info can be preserved.
#39522 on master:
on this branch:
#40044 on master:
on this branch: