Skip to content

Attempt to produce an error message to indicate that there are less l… #24068

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

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 9 additions & 1 deletion lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,15 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):

# if got both handles and labels as kwargs, make same length
if handles and labels:
handles, labels = zip(*zip(handles, labels))
lengthOfHandles = []
lengthOfLabels = []
lengthOfHandles, LengthOfLabels = _get_legend_handles_labels(axs, handlers)
if len(lengthOfHandles) != len(lengthOfLabels):
log.warning("The amount of labels do not match the number of legends."
"Please note that they have to be the same size in order to"
"produce accurate graph representations.")
else:
handles, labels = zip(*zip(handles, labels))

elif handles is not None and labels is None:
labels = [handle.get_label() for handle in handles]
Expand Down