-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update handling of sequence labels for plot #27767
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
This comment was marked as outdated.
This comment was marked as outdated.
2368337
to
2d610df
Compare
This comment was marked as outdated.
This comment was marked as outdated.
2d610df
to
be1ebc2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
5a029d8
to
af43359
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
af43359
to
a1ef60c
Compare
Hid a bunch of comments because they discuss issues with |
lib/matplotlib/axes/_base.py
Outdated
|
||
if cbook.is_scalar_or_string(label): | ||
labels = [label] * n_datasets | ||
else: | ||
if len(label) != n_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.
Optional but inverting the if branches is more readable:
if len(label) != n_datasets: | |
if len(label) == n_datasets: | |
… |
- you remove the negation in the condition
- And the short and good-case branch comes first
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'm a little sleepy but I think this if
doesn't have an else
.
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.
Oh, I think I get it. I can have a look this evening (on the wrong computer at the moment).
a1ef60c
to
ffc7ab0
Compare
Anyone can merge on green CI |
PR summary
Closes #27762.
plot(x, y, label=['foo'])
where y is 1D now results in the legend label "foo" instead of "['foo']" (immediate change).plot(x, y, label=sequence)
where y is 1D and sequence is not of length 1 is deprecated to error in future.PR checklist