8000 Backport PR #23813: Triplot duplicated label · matplotlib/matplotlib@713d13c · GitHub
[go: up one dir, main page]

Skip to content

Commit 713d13c

Browse files
amartinez1224meeseeksmachine
authored andcommitted
Backport PR #23813: Triplot duplicated label
1 parent f394755 commit 713d13c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/matplotlib/tests/test_triangulation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,3 +1299,15 @@ def test_triplot_with_ls(fig_test, fig_ref):
12991299
data = [[0, 1, 2]]
13001300
fig_test.subplots().triplot(x, y, data, ls='--')
13011301
fig_ref.subplots().triplot(x, y, data, linestyle='--')
1302+
1303+
1304+
def test_triplot_label():
1305+
x = [0, 2, 1]
1306+
y = [0, 0, 1]
1307+
data = [[0, 1, 2]]
1308+
fig, ax = plt.subplots()
1309+
lines, markers = ax.triplot(x, y, data, label='label')
1310+
handles, labels = ax.get_legend_handles_labels()
1311+
assert labels == ['label']
1312+
assert len(handles) == 1
1313+
assert handles[0] is lines

lib/matplotlib/tri/triplot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def triplot(ax, *args, **kwargs):
7777
**kw,
7878
'linestyle': 'None', # No line to draw.
7979
}
80+
kw_markers.pop('label', None)
8081
if marker not in [None, 'None', '', ' ']:
8182
tri_markers = ax.plot(x, y, **kw_markers)
8283
else:

0 commit comments

Comments
 (0)
0