@@ -246,6 +246,35 @@ def test_legend_stackplot():
246
246
ax .legend (loc = 0 )
247
247
248
248
249
+ @cleanup
250
+ def _test_rcparams_helper (test_rcparams , facecolor_target , edgecolor_target ):
251
+ with mpl .rc_context (test_rcparams ):
252
+ fig , ax = plt .subplots (1 , 1 )
253
+ t = np .linspace (0 , 2 * np .pi )
254
+ ax .plot (t , np .sin (t ), label = 'sin' )
255
+ ax .plot (t , np .cos (t ), label = 'cos' )
256
+ leg = ax .legend ()
257
+
258
+ assert_equal (mpl .colors .colorConverter .to_rgba (facecolor_target ),
259
+ leg .legendPatch .get_facecolor ())
260
+
261
+ assert_equal (mpl .colors .colorConverter .to_rgba (edgecolor_target ),
262
+ leg .legendPatch .get_edgecolor ())
263
+
264
+
265
+ def test_rcparams_ ():
266
+ test_vals = [({}, mpl .rcParams ['axes.facecolor' ],
267
+ mpl .rcParams ['axes.edgecolor' ]),
268
+ ({'axes.facecolor' : 'r' , 'axes.edgecolor' : 'c' }, 'r' , 'c' ),
269
+ ({'axes.facecolor' : 'r' , 'axes.edgecolor' : 'c' ,
270
+ 'legend.facecolor' : 'w' , 'legend.edgecolor' : 'k' },
271
+ 'w' , 'k' ),
272
+ ]
273
+
274
+ for rc_dict , face , edge in test_vals :
275
+ yield _test_rcparams_helper , rc_dict , face , edge
276
+
277
+
249
278
if __name__ == '__main__' :
250
279
import nose
251
280
nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments