Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Description
We already discouragelegend(labels)
in the docs:
Note: This way of using is discouraged, because the relation between plot elements and labels is only implicit by their order and can easily be mixed up.
Additionally, this API is very permissive:
- If there are less labels than artists, only the first
len(labels)
artists are labelled. - If there are more labels than artists, additional labels are silently ignored.
IMHO this length adaption is very prone to hiding errors.
Possible options if the number of labels does not match the number of available handles:
- Emit a warning.
- Deprecate the length adaption and error out in the future.
- Deprecate the whole
legend(labels)
API, because it's prone to misuse anyway. (This would us also enable in the long run to migrate to an explicitlegend(handles=None, labels=None, **kwargs)
signature instead oflegend(*args, **kwargs)
.)
I tend to go with option 2. Comments are welcome.
Inspired by#18096.