8000 Add test to close legend issue · matplotlib/matplotlib@db88944 · GitHub
[go: up one dir, main page]

Skip to content

Commit db88944

Browse files
committed
Add test to close legend issue
1 parent 1b2a3c9 commit db88944

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/matplotlib/tests/test_legend.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pytest
77

8-
from matplotlib.testing.decorators import image_comparison
8+
from matplotlib.testing.decorators import check_figures_equal, image_comparison
99
import matplotlib.pyplot as plt
1010
import matplotlib as mpl
1111
import matplotlib.transforms as mtransforms
@@ -910,3 +910,17 @@ def test_setting_alpha_keeps_polycollection_color():
910910
patch.set_alpha(0.5)
911911
assert patch.get_facecolor()[:3] == tuple(pc.get_facecolor()[0][:3])
912912
assert patch.get_edgecolor()[:3] == tuple(pc.get_edgecolor()[0][:3])
913+
914+
915+
@check_figures_equal(extensions=["png"])
916+
def test_legend_markers_from_Line2d(fig_test, fig_ref):
917+
# Test that markers can be copied for legend lines (#17960)
918+
lines = [mlines.Line2D([0], [0], ls='None', marker='.') for i in range(2)]
919+
labels = [1, 2]
920+
921+
legend = fig_ref.gca().legend(lines,labels)
922+
923+
new_lines = legend.get_lines()
924+
new_labels = [text.get_text() for text in legend.get_texts()]
925+
926+
fig_test.gca().legend(new_lines, new_labels)

0 commit comments

Comments
 (0)
0