Don't warn when legend() finds no labels.#6753
Conversation
|
I agree with the rationale here. Is there, or should there be, a simple test to ensure that calling legend with no labels works correctly? |
|
I can add a test that just does |
|
Yes. |
|
I suspect the reason this is here is to deal with the case of ax.plot(x, y)
ax.legend()
# MATPLOTLIB LEGENDS ARE BROKEN!!!!!1!style bug reports. |
|
Well, a warning you know to be spurious is still a (minor) annoyance. Another option would be to add an |
|
A kwarg to defeat a warning? No, I would prefer that we decide: warn, or don't warn. |
|
Agreed. No kwarg. If a user expects a warning and doesn't want it, they can On Sat, Jul 16, 2016 at 2:54 PM, Eric Firing notifications@github.com
|
|
I agree, the warning is pretty annoying |
|
👍 on removing the warning. Can you add an entry in whats_new? |
There's no warning when calling `plot([])`, so I don't see why there should be one when calling `legend()` with no labeled artists either (except for catching basic bugs where someone forgets to pass `label=...`, but such errors are pretty obvious visually anyways and the warning doesn't help when only *some* labels are missing). Typical use case: making a complicated plot with a lot of elements which each may or may not have a label; now I need to separately keep track of whether I actually *did* add a label before deciding whether to call `legend()` at the end.
8daaf5e to
2fd8362
Compare
|
done. |
There's no warning when calling
plot([]), so I don't see why there should beone when calling
legend()with no labeled artists either (except for catchingbasic bugs where someone forgets to pass
label=..., but such errors arepretty obvious visually anyways and the warning doesn't help when only some
labels are missing).
Typical use case: making a complicated plot with a lot of elements which each
may or may not have a label; now I need to separately keep track of whether I
actually did add a label before deciding whether to call
legend()at theend.