@@ -1154,63 +1154,63 @@ def test_legend_labelcolor_linecolor_histograms():
11541154 assert_last_legend_patch_color (h , leg , 'r' , facecolor = True )
11551155
11561156
1157- def assert_last_legend_linemarker_color (plot , leg , expected_color ,
1158- color = False , facecolor = False , edgecolor = False ):
1157+ def assert_last_legend_linemarker_color (line_marker , leg , expected_color , color = False ,
1158+ facecolor = False , edgecolor = False ):
11591159 """
11601160 Check that line marker color, legend handle color, and legend label color all
11611161 match the expected input. Provide color, facecolor and edgecolor flags to clarify
11621162 which feature to match.
11631163 """
11641164 label_color = leg .texts [- 1 ].get_color ()
11651165 leg_marker = leg .get_lines ()[- 1 ]
1166- plot_marker = plot [0 ]
11671166 assert mpl .colors .same_color (label_color , expected_color )
11681167 if color :
11691168 assert mpl .colors .same_color (label_color , leg_marker .get_color ())
1170- assert mpl .colors .same_color (label_color , plot_marker .get_color ())
1169+ assert mpl .colors .same_color (label_color , line_marker .get_color ())
11711170 if facecolor :
11721171 assert mpl .colors .same_color (label_color , leg_marker .get_markerfacecolor ())
1173- assert mpl .colors .same_color (label_color , plot_marker .get_markerfacecolor ())
1172+ assert mpl .colors .same_color (label_color , line_marker .get_markerfacecolor ())
11741173 if edgecolor :
11751174 assert mpl .colors .same_color (label_color , leg_marker .get_markeredgecolor ())
1176- assert mpl .colors .same_color (label_color , plot_marker .get_markeredgecolor ())
1175+ assert mpl .colors .same_color (label_color , line_marker .get_markeredgecolor ())
11771176
11781177
11791178def test_legend_labelcolor_linecolor_plot ():
11801179 x = np .arange (5 )
11811180
11821181 # testing line plot
11831182 fig , ax = plt .subplots ()
1184- p = ax .plot (x , c = 'r' , label = "red line with a red label" )
1183+ l , = ax .plot (x , c = 'r' , label = "red line with a red label" )
11851184 leg = ax .legend (labelcolor = 'linecolor' )
1186- assert_last_legend_linemarker_color (p , leg , 'r' , color = True )
1185+ assert_last_legend_linemarker_color (l , leg , 'r' , color = True )
11871186
11881187 # testing c, fc, and ec combinations for maker plots
1189- p = ax .plot (x , 'o' , c = 'r' , label = "red circles with a red label" )
1188+ l , = ax .plot (x , 'o' , c = 'r' , label = "red circles with a red label" )
11901189 leg = ax .legend (labelcolor = 'linecolor' )
1191- assert_last_legend_linemarker_color (p , leg , 'r' , color = True )
1190+ assert_last_legend_linemarker_color (l , leg , 'r' , color = True )
11921191
1193- p = ax .plot (x , 'o' , c = 'r' , mec = 'b' , label = "red circles, blue edges, red label" )
1192+ l , = ax .plot (x , 'o' , c = 'r' , mec = 'b' , label = "red circles, blue edges, red label" )
11941193 leg = ax .legend (labelcolor = 'linecolor' )
1195- assert_last_legend_linemarker_color (p , leg , 'r' , color = True )
1194+ assert_last_legend_linemarker_color (l , leg , 'r' , color = True )
11961195
1197- p = ax .plot (x , 'o' , mfc = 'r' , mec = 'b' , label = "red circles, blue edges, red label" )
1196+ l , = ax .plot (x , 'o' , mfc = 'r' , mec = 'b' , label = "red circles, blue edges, red label" )
11981197 leg = ax .legend (labelcolor = 'linecolor' )
1199- assert_last_legend_linemarker_color (p , leg , 'r' , facecolor = True )
1198+ assert_last_legend_linemarker_color (l , leg , 'r' , facecolor = True )
12001199
12011200 # 'none' cases
1202- p = ax .plot (x , 'o' , mfc = 'none' , mec = 'b' , label = "blue unfilled circles, blue label" )
1201+ l , = ax .plot (x , 'o' , mfc = 'none' , mec = 'b' ,
1202+ label = "blue unfilled circles, blue label" )
12031203 leg = ax .legend (labelcolor = 'linecolor' )
1204- assert_last_legend_linemarker_color (p , leg , 'b' , edgecolor = True )
1204+ assert_last_legend_linemarker_color (l , leg , 'b' , edgecolor = True )
12051205
1206- p = ax .plot (x , 'o' , mfc = 'r' , mec = 'none' , label = "red edgeless circles, red label" )
1206+ l , = ax .plot (x , 'o' , mfc = 'r' , mec = 'none' , label = "red edgeless circles, red label" )
12071207 leg = ax .legend (labelcolor = 'linecolor' )
1208- assert_last_legend_linemarker_color (p , leg , 'r' , facecolor = True )
1208+ assert_last_legend_linemarker_color (l , leg , 'r' , facecolor = True )
12091209
1210- p = ax .plot (x , 'o' , c = 'none' , mec = 'none' ,
1211- label = "black label despite invisible circles for dummy entries" )
1210+ l , = ax .plot (x , 'o' , c = 'none' , mec = 'none' ,
1211+ label = "black label despite invisible circles for dummy entries" )
12121212 leg = ax .legend (labelcolor = 'linecolor' )
1213- assert_last_legend_linemarker_color (p , leg , 'k' )
1213+ assert_last_legend_linemarker_color (l , leg , 'k' )
12141214
12151215
12161216def assert_last_legend_scattermarker_color (scatter_marker , leg , expected_color ,
@@ -1236,31 +1236,31 @@ def test_legend_labelcolor_linecolor_scatter():
12361236
12371237 # testing c, fc, and ec combinations for scatter plots
12381238 fig , ax = plt .subplots ()
1239- p = ax .scatter (x , x , c = 'r' , label = "red circles with a red label" )
1239+ s = ax .scatter (x , x , c = 'r' , label = "red circles with a red label" )
12401240 leg = ax .legend (labelcolor = 'linecolor' )
1241- assert_last_legend_scattermarker_color (p , leg , 'r' , facecolor = True )
1241+ assert_last_legend_scattermarker_color (s , leg , 'r' , facecolor = True )
12421242
1243- p = ax .scatter (x , x , c = 'r' , ec = 'b' , label = "red circles, blue edges, red label" )
1243+ s = ax .scatter (x , x , c = 'r' , ec = 'b' , label = "red circles, blue edges, red label" )
12441244 leg = ax .legend (labelcolor = 'linecolor' )
1245- assert_last_legend_scattermarker_color (p , leg , 'r' , facecolor = True )
1245+ assert_last_legend_scattermarker_color (s , leg , 'r' , facecolor = True )
12461246
1247- p = ax .scatter (x , x , fc = 'r' , ec = 'b' , label = "red circles, blue edges, red label" )
1247+ s = ax .scatter (x , x , fc = 'r' , ec = 'b' , label = "red circles, blue edges, red label" )
12481248 leg = ax .legend (labelcolor = 'linecolor' )
1249- assert_last_legend_scattermarker_color (p , leg , 'r' , facecolor = True )
1249+ assert_last_legend_scattermarker_color (s , leg , 'r' , facecolor = True )
12501250
12511251 # 'none' cases
1252- p = ax .scatter (x , x , fc = 'none' , ec = 'b' , label = "blue unfilled circles, blue label" )
1252+ s = ax .scatter (x , x , fc = 'none' , ec = 'b' , label = "blue unfilled circles, blue label" )
12531253 leg = ax .legend (labelcolor = 'linecolor' )
1254- assert_last_legend_scattermarker_color (p , leg , 'b' , edgecolor = True )
1254+ assert_last_legend_scattermarker_color (s , leg , 'b' , edgecolor = True )
12551255
1256- p = ax .scatter (x , x , fc = 'r' , ec = 'none' , label = "red edgeless circles, red label" )
1256+ s = ax .scatter (x , x , fc = 'r' , ec = 'none' , label = "red edgeless circles, red label" )
12571257 leg = ax .legend (labelcolor = 'linecolor' )
1258- assert_last_legend_scattermarker_color (p , leg , 'r' , facecolor = True )
1258+ assert_last_legend_scattermarker_color (s , leg , 'r' , facecolor = True )
12591259
1260- p = ax .scatter (x , x , c = 'none' , ec = 'none' ,
1260+ s = ax .scatter (x , x , c = 'none' , ec = 'none' ,
12611261 label = "black label despite invisible circles for dummy entries" )
12621262 leg = ax .legend (labelcolor = 'linecolor' )
1263- assert_last_legend_scattermarker_color (p , leg , 'k' )
1263+ assert_last_legend_scattermarker_color (s , leg , 'k' )
12641264
12651265
12661266@pytest .mark .filterwarnings ("ignore:No artists with labels found to put in legend" )
0 commit comments