@@ -259,7 +259,7 @@ def __init__(self,
259259 facecolor = None , # defaults to rc figure.facecolor
260260 edgecolor = None , # defaults to rc figure.edgecolor
261261 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
263263 subplotpars = None , # default to rc
264264 tight_layout = None , # default to rc figure.autolayout
265265 ):
@@ -302,6 +302,8 @@ def __init__(self,
302302 facecolor = rcParams ['figure.facecolor' ]
303303 if edgecolor is None :
304304 edgecolor = rcParams ['figure.edgecolor' ]
305+ if frameon is None :
306+ frameon = rcParams ['figure.frameon' ]
305307
306308 self .dpi_scale_trans = Affine2D ()
307309 self .dpi = dpi
@@ -1306,7 +1308,8 @@ def savefig(self, *args, **kwargs):
13061308
13071309 savefig(fname, dpi=None, facecolor='w', edgecolor='w',
13081310 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)
13101313
13111314 The output formats available depend on the backend being used.
13121315
@@ -1355,6 +1358,11 @@ def savefig(self, *args, **kwargs):
13551358 transparency of these patches will be restored to their
13561359 original values upon exit of this function.
13571360
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+
13581366 *bbox_inches*:
13591367 Bbox in inches. Only the given portion of the figure is
13601368 saved. If 'tight', try to figure out the tight bbox of
@@ -1371,8 +1379,9 @@ def savefig(self, *args, **kwargs):
13711379 """
13721380
13731381 kwargs .setdefault ('dpi' , rcParams ['savefig.dpi' ])
1374-
1382+ frameon = kwargs . pop ( 'frameon' , rcParams [ 'savefig.frameon' ])
13751383 transparent = kwargs .pop ('transparent' , False )
1384+
13761385 if transparent :
13771386 kwargs .setdefault ('facecolor' , 'none' )
13781387 kwargs .setdefault ('edgecolor' , 'none' )
@@ -1387,8 +1396,15 @@ def savefig(self, *args, **kwargs):
13871396 kwargs .setdefault ('facecolor' , rcParams ['savefig.facecolor' ])
13881397 kwargs .setdefault ('edgecolor' , rcParams ['savefig.edgecolor' ])
13891398
1399+ if frameon :
1400+ original_frameon = self .get_frameon ()
1401+ self .set_frameon (frameon )
1402+
13901403 self .canvas .print_figure (* args , ** kwargs )
13911404
1405+ if frameon :
1406+ self .set_frameon (original_frameon )
1407+
13921408 if transparent :
13931409 for ax , cc in zip (self .axes , original_axes_colors ):
13941410 ax .patch .set_facecolor (cc [0 ])
0 commit comments