From 4b26589442de523f0b688b1bb02983618632f4df Mon Sep 17 00:00:00 2001 From: carverde <90798442+carverde@users.noreply.github.com> Date: Sat, 1 Oct 2022 23:26:32 -0400 Subject: [PATCH] Attempt to produce an error message to indicate that there are less labels than legends --- lib/matplotlib/legend.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index 20d4a76e0db3..c31a3c852aca 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -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] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy