MNT: expire legend-related deprecations by rcomer · Pull Request #29832 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/api/next_api_changes/behavior/29832-REC.rst
7 changes: 0 additions & 7 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,6 @@ def _plot_args(self, axes, tup, kwargs, *,
labels = [label] * n_datasets
elif len(label) == n_datasets:
labels = label
elif n_datasets == 1:
msg = (f'Passing label as a length {len(label)} sequence when '
'plotting a single dataset is deprecated in Matplotlib 3.9 '
'and will error in 3.11. To keep the current behavior, '
'cast the sequence to string before passing.')
_api.warn_deprecated('3.9', message=msg)
labels = [label]
else:
raise ValueError(
f"label must be scalar or have the same length as the input "
Expand Down
8 changes: 3 additions & 5 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):
legend(handles=handles, labels=labels)

The behavior for a mixture of positional and keyword handles and labels
is undefined and issues a warning; it will be an error in the future.
is undefined and raises an error.

Parameters
----------
Expand Down Expand Up @@ -1319,10 +1319,8 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):
handlers = kwargs.get('handler_map')

if (handles is not None or labels is not None) and args:
_api.warn_deprecated("3.9", message=(
"You have mixed positional and keyword arguments, some input may "
"be discarded. This is deprecated since %(since)s and will "
"become an error in %(removal)s."))
raise TypeError("When passing handles and labels, they must both be "
"passed positionally or both as keywords.")

if (hasattr(handles, "__len__") and
hasattr(labels, "__len__") and
Expand Down
32 changes: 10 additions & 22 deletions lib/matplotlib/tests/test_legend.py