diff --git a/lib/matplotlib/tests/test_triangulation.py b/lib/matplotlib/tests/test_triangulation.py index 365f9a0360cd..75b2a51dfaf9 100644 --- a/lib/matplotlib/tests/test_triangulation.py +++ b/lib/matplotlib/tests/test_triangulation.py @@ -1299,3 +1299,15 @@ def test_triplot_with_ls(fig_test, fig_ref): data = [[0, 1, 2]] fig_test.subplots().triplot(x, y, data, ls='--') fig_ref.subplots().triplot(x, y, data, linestyle='--') + + +def test_triplot_label(): + x = [0, 2, 1] + y = [0, 0, 1] + data = [[0, 1, 2]] + fig, ax = plt.subplots() + lines, markers = ax.triplot(x, y, data, label='label') + handles, labels = ax.get_legend_handles_labels() + assert labels == ['label'] + assert len(handles) == 1 + assert handles[0] is lines diff --git a/lib/matplotlib/tri/triplot.py b/lib/matplotlib/tri/triplot.py index 5f7b15f06d0f..553b4b4482bf 100644 --- a/lib/matplotlib/tri/triplot.py +++ b/lib/matplotlib/tri/triplot.py @@ -77,6 +77,7 @@ def triplot(ax, *args, **kwargs): **kw, 'linestyle': 'None', # No line to draw. } + kw_markers.pop('label', None) if marker not in [None, 'None', '', ' ']: tri_markers = ax.plot(x, y, **kw_markers) else: