-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: fix Series.plot label setting #10131
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
Because of the default value of https://github.com/pydata/pandas/blob/master/pandas/tools/plotting.py#L2492 |
That's what I thought. Ok, I suppose we'll keep it like that for now. So |
s.name = 'NAME' | ||
ax = s.plot(legend=True) | ||
self._check_legend_labels(ax, labels=['NAME']) | ||
|
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 add here a test for the case where the series has a name, but you provide a label (so add ´s.plot(label='LABEL', legend=True)´ and then check the legend label is LABEL and not NAME)?
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.
Good call. Updated.
I think this is ready then. Will merge once Travis is green. |
BUG: fix Series.plot label setting
Thanks @TomAugspurger ! |
@TomAugspurger Thanks, Tom. I'm trying to tie back to my commit - #9574 . I don't have that .pop() in _compute_plot_data() within my commit. Was that added somewhere else? In fact I deleted a .pop() line in my commit. |
@schmohlio This specific line that @TomAugspurger changed in this PR was in any case not introduced by your PR (https://github.com/pydata/pandas/blame/95dc0506f1a9237b0a34a1d26eba1e1a8d357758/pandas/tools/plotting.py#L1001), so certainly not necessary a regression by your PR! (and anyway, who introduced it does not really matter, as it is reviewed by multiple people and we should improve the test suite to catch such things) |
@jorisvandenbossche both thoughts makes a lot of sense. Just wanted to see if I could help at any point. Thanks again for you and your team's great work. |
Closes #10119, a regression in 0.16.1
Basically
Series.plot(label='foo')
isn't actually setting the label.I want to look at one more thing. With this fix you'd need
to get the legend to actually show up. I can't remember what the old behavior was. At least for seaborn, setting a label implies that the legend should be drawn (e.g.
sns.kdeplot(s, label='foo')
)