@@ -1154,63 +1154,63 @@ def test_legend_labelcolor_linecolor_histograms():
1154
1154
assert_last_legend_patch_color (h , leg , 'r' , facecolor = True )
1155
1155
1156
1156
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 ):
1159
1159
"""
1160
1160
Check that line marker color, legend handle color, and legend label color all
1161
1161
match the expected input. Provide color, facecolor and edgecolor flags to clarify
1162
1162
which feature to match.
1163
1163
"""
1164
1164
label_color = leg .texts [- 1 ].get_color ()
1165
1165
leg_marker = leg .get_lines ()[- 1 ]
1166
- plot_marker = plot [0 ]
1167
1166
assert mpl .colors .same_color (label_color , expected_color )
1168
1167
if color :
1169
1168
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 ())
1171
1170
if facecolor :
1172
1171
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 ())
1174
1173
if edgecolor :
1175
1174
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 ())
1177
1176
1178
1177
1179
1178
def test_legend_labelcolor_linecolor_plot ():
1180
1179
x = np .arange (5 )
1181
1180
1182
1181
# testing line plot
1183
1182
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" )
1185
1184
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 )
1187
1186
1188
1187
# 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" )
1190
1189
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 )
1192
1191
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" )
1194
1193
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 )
1196
1195
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" )
1198
1197
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 )
1200
1199
1201
1200
# '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" )
1203
1203
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 )
1205
1205
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" )
1207
1207
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 )
1209
1209
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" )
1212
1212
leg = ax .legend (labelcolor = 'linecolor' )
1213
- assert_last_legend_linemarker_color (p , leg , 'k' )
1213
+ assert_last_legend_linemarker_color (l , leg , 'k' )
1214
1214
1215
1215
1216
1216
def assert_last_legend_scattermarker_color (scatter_marker , leg , expected_color ,
@@ -1236,31 +1236,31 @@ def test_legend_labelcolor_linecolor_scatter():
1236
1236
1237
1237
# testing c, fc, and ec combinations for scatter plots
1238
1238
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" )
1240
1240
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 )
1242
1242
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" )
1244
1244
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 )
1246
1246
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" )
1248
1248
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 )
1250
1250
1251
1251
# '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" )
1253
1253
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 )
1255
1255
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" )
1257
1257
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 )
1259
1259
1260
- p = ax .scatter (x , x , c = 'none' , ec = 'none' ,
1260
+ s = ax .scatter (x , x , c = 'none' , ec = 'none' ,
1261
1261
label = "black label despite invisible circles for dummy entries" )
1262
1262
leg = ax .legend (labelcolor = 'linecolor' )
1263
- assert_last_legend_scattermarker_color (p , leg , 'k' )
1263
+ assert_last_legend_scattermarker_color (s , leg , 'k' )
1264
1264
1265
1265
1266
1266
@pytest .mark .filterwarnings ("ignore:No artists with labels found to put in legend" )
0 commit comments