File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 5
5
import numpy as np
6
6
import pytest
7
7
8
- from matplotlib .testing .decorators import image_comparison
8
+ from matplotlib .testing .decorators import check_figures_equal , image_comparison
9
9
import matplotlib .pyplot as plt
10
10
import matplotlib as mpl
11
11
import matplotlib .transforms as mtransforms
@@ -910,3 +910,19 @@ def test_setting_alpha_keeps_polycollection_color():
910
910
patch .set_alpha (0.5 )
911
911
assert patch .get_facecolor ()[:3 ] == tuple (pc .get_facecolor ()[0 ][:3 ])
912
912
assert patch .get_edgecolor ()[:3 ] == tuple (pc .get_edgecolor ()[0 ][:3 ])
913
+
914
+
915
+ def test_legend_markers_from_Line2d ():
916
+ # Test that markers can be copied for legend lines (#17960)
917
+ _markers = ['.' , '*' , 'v' ]
918
+ fig , ax = plt .subplots ()
919
+ lines = [mlines .Line2D ([0 ], [0 ], ls = 'None' , marker = mark ) for mark in _markers ]
920
+ labels = ["foo" , "bar" , "xyzzy" ]
921
+ markers = [line .get_marker () for line in lines ]
922
+ legend = ax .legend (lines , labels )
923
+
924
+ new_markers = [line .get_marker () for line in legend .get_lines ()]
925
+ new_labels = [text .get_text () for text in legend .get_texts ()]
926
+
927
+ assert markers == new_markers == _markers
928
+ assert labels == new_labels
You can’t perform that action at this time.
0 commit comments