@@ -259,7 +259,7 @@ def __init__(self,
259
259
facecolor = None , # defaults to rc figure.facecolor
260
260
edgecolor = None , # defaults to rc figure.edgecolor
261
261
linewidth = 0.0 , # the default linewidth of the frame
262
- frameon = True , # whether or not to draw the figure frame
262
+ frameon = None , # whether or not to draw the figure frame
263
263
subplotpars = None , # default to rc
264
264
tight_layout = None , # default to rc figure.autolayout
265
265
):
@@ -302,6 +302,8 @@ def __init__(self,
302
302
facecolor = rcParams ['figure.facecolor' ]
303
303
if edgecolor is None :
304
304
edgecolor = rcParams ['figure.edgecolor' ]
305
+ if frameon is None :
306
+ frameon = rcParams ['figure.frameon' ]
305
307
306
308
self .dpi_scale_trans = Affine2D ()
307
309
self .dpi = dpi
@@ -1306,7 +1308,8 @@ def savefig(self, *args, **kwargs):
1306
1308
1307
1309
savefig(fname, dpi=None, facecolor='w', edgecolor='w',
1308
1310
orientation='portrait', papertype=None, format=None,
1309
- transparent=False, bbox_inches=None, pad_inches=0.1)
1311
+ transparent=False, bbox_inches=None, pad_inches=0.1,
1312
+ frameon=None)
1310
1313
1311
1314
The output formats available depend on the backend being used.
1312
1315
@@ -1355,6 +1358,11 @@ def savefig(self, *args, **kwargs):
1355
1358
transparency of these patches will be restored to their
1356
1359
original values upon exit of this function.
1357
1360
1361
+ *frameon*:
1362
+ If *True*, the figure patch will be colored, if *False*, the
1363
+ figure background will be transparent. If not provided, the
1364
+ rcParam 'savefig.frameon' will be used.
1365
+
1358
1366
*bbox_inches*:
1359
1367
Bbox in inches. Only the given portion of the figure is
1360
1368
saved. If 'tight', try to figure out the tight bbox of
@@ -1371,8 +1379,9 @@ def savefig(self, *args, **kwargs):
1371
1379
"""
1372
1380
1373
1381
kwargs .setdefault ('dpi' , rcParams ['savefig.dpi' ])
1374
-
1382
+ frameon = kwargs . pop ( 'frameon' , rcParams [ 'savefig.frameon' ])
1375
1383
transparent = kwargs .pop ('transparent' , False )
1384
+
1376
1385
if transparent :
1377
1386
kwargs .setdefault ('facecolor' , 'none' )
1378
1387
kwargs .setdefault ('edgecolor' , 'none' )
@@ -1387,8 +1396,15 @@ def savefig(self, *args, **kwargs):
1387
1396
kwargs .setdefault ('facecolor' , rcParams ['savefig.facecolor' ])
1388
1397
kwargs .setdefault ('edgecolor' , rcParams ['savefig.edgecolor' ])
1389
1398
1399
+ if frameon :
1400
+ original_frameon = self .get_frameon ()
1401
+ self .set_frameon (frameon )
1402
+
1390
1403
self .canvas .print_figure (* args , ** kwargs )
1391
1404
1405
+ if frameon :
1406
+ self .set_frameon (original_frameon )
1407
+
1392
1408
if transparent :
1393
1409
for ax , cc in zip (self .axes , original_axes_colors ):
1394
1410
ax .patch .set_facecolor (cc [0 ])
0 commit comments