8000 Explanatory comment in figure.legend · matplotlib/matplotlib@35a74eb · GitHub
[go: up one dir, main page]

Skip to content

Commit 35a74eb

Browse files
committed
Explanatory comment in figure.legend
1 parent 12c5be9 commit 35a74eb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,11 +1412,19 @@ def legend(self, *args, **kwargs):
14121412
.. plot:: mpl_examples/pylab_examples/figlegend_demo.py
14131413
"""
14141414

1415+
# If no arguments given, collect up all the artists on the figure
14151416
if len(args) == 0:
14161417
handles = []
14171418
labels = []
14181419

14191420
def in_handles(h, l):
1421+
'''
1422+
Method to check if we already have a given handle and label.
1423+
1424+
We consdier two handles to be the same if they share a label,
1425+
color, facecolor, and edgecolor.
1426+
'''
1427+
# Loop through each handle and label already collected
14201428
for f_h, f_l in zip(handles, labels):
14211429
if f_l != l:
14221430
continue
@@ -1428,11 +1436,13 @@ def in_handles(h, l):
14281436
continue
14291437
except AttributeError:
14301438
pass
1439+
14311440
try:
14321441
if f_h.get_facecolor() != h.get_facecolor():
14331442
continue
14341443
except AttributeError:
14351444
pass
1445+
14361446
try:
14371447
if f_h.get_edgecolor() != h.get_edgecolor():
14381448
continue

0 commit comments

Comments
 (0)
0