8000 Triplot duplicated label (#23813) · matplotlib/matplotlib@3b79f63 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b79f63

Browse files
Triplot duplicated label (#23813)
* label removed * Test for triplot duplicated label * NewLine at end of file (flake 8) * Flake 8 compliant * Explicit logic test
1 parent ae53649 commit 3b79f63

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