Skip to content
Merged
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
18 changes: 11 additions & 7 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from matplotlib import docstring
from matplotlib.artist import Artist, allow_rasterization
from matplotlib.cbook import silent_list, is_hashable
import matplotlib.colors as colors
from matplotlib.font_manager import FontProperties
from matplotlib.lines import Line2D
from matplotlib.patches import Patch, Rectangle, Shadow, FancyBboxPatch
Expand Down Expand Up @@ -1339,7 +1340,7 @@ def _get_legend_handles_labels(axs, legend_handler_map=None):
labels = []

def _in_handles(h, l):
# Method to check if we already have a given handle and label.
# Method to check if we already have a given handle and label.
# Consider two handles to be the same if they share a label,
# color, facecolor, and edgecolor.

Expand All @@ -1350,17 +1351,20 @@ def _in_handles(h, l):
if type(f_h) != type(h):
continue
try:
if f_h.get_color() != h.get_color():
if (colors.to_rgba_array(f_h.get_color()) !=
colors.to_rgba_array(h.get_color())).any():
continue
except AttributeError:
pass
try:
if f_h.get_facecolor() != h.get_facecolor():
if (colors.to_rgba_array(f_h.get_facecolor()) !=
colors.to_rgba_array(h.get_facecolor())).any():
continue
except AttributeError:
pass
try:
if f_h.get_edgecolor() != h.get_edgecolor():
if (colors.to_rgba_array(f_h.get_edgecolor()) !=
colors.to_rgba_array(h.get_edgecolor())).any():
continue
except AttributeError:
pass
Expand All @@ -1369,9 +1373,9 @@ def _in_handles(h, l):

for handle in _get_legend_handles(axs, legend_handler_map):
label = handle.get_label()
if (label
and not label.startswith('_')
and not _in_handles(handle, label)):
if (label and
not label.startswith('_') and
not _in_handles(handle, label)):
handles.append(handle)
labels.append(label)
return handles, labels
Expand Down
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