From d883cdb89df91cdbf8358e49ade9d6d95be5693a Mon Sep 17 00:00:00 2001 From: Till Stensitzki Date: Sun, 31 Mar 2013 18:03:14 +0200 Subject: [PATCH 1/2] added figure.frameon and savefig.frameon to rcparams --- lib/matplotlib/figure.py | 21 ++++++++++++++++++--- lib/matplotlib/rcsetup.py | 2 ++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 3b97ca45328d..67911c358e0e 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -259,7 +259,7 @@ def __init__(self, facecolor=None, # defaults to rc figure.facecolor edgecolor=None, # defaults to rc figure.edgecolor linewidth=0.0, # the default linewidth of the frame - frameon=True, # whether or not to draw the figure frame + frameon=None, # whether or not to draw the figure frame subplotpars=None, # default to rc tight_layout=None, # default to rc figure.autolayout ): @@ -302,6 +302,8 @@ def __init__(self, facecolor = rcParams['figure.facecolor'] if edgecolor is None: edgecolor = rcParams['figure.edgecolor'] + if frameon is None: + frameon = rcParams['figure.frameon'] self.dpi_scale_trans = Affine2D() self.dpi = dpi @@ -1306,7 +1308,8 @@ def savefig(self, *args, **kwargs): savefig(fname, dpi=None, facecolor='w', edgecolor='w', orientation='portrait', papertype=None, format=None, - transparent=False, bbox_inches=None, pad_inches=0.1) + transparent=False, bbox_inches=None, pad_inches=0.1, + frameon=None) The output formats available depend on the backend being used. @@ -1355,6 +1358,10 @@ def savefig(self, *args, **kwargs): transparency of these patches will be restored to their original values upon exit of this function. + *frameon*: + If *True*, the figure patch will be colored. Else the figure + background will be transparent. + *bbox_inches*: Bbox in inches. Only the given portion of the figure is saved. If 'tight', try to figure out the tight bbox of @@ -1371,8 +1378,9 @@ def savefig(self, *args, **kwargs): """ kwargs.setdefault('dpi', rcParams['savefig.dpi']) - + frameon = kwargs.pop('frameon', rcParams['savefig.frameon']) transparent = kwargs.pop('transparent', False) + if transparent: kwargs.setdefault('facecolor', 'none') kwargs.setdefault('edgecolor', 'none') @@ -1387,8 +1395,15 @@ def savefig(self, *args, **kwargs): kwargs.setdefault('facecolor', rcParams['savefig.facecolor']) kwargs.setdefault('edgecolor', rcParams['savefig.edgecolor']) + if frameon: + original_frameon = self.get_frameon() + self.set_frameon(frameon) + self.canvas.print_figure(*args, **kwargs) + if frameon: + self.set_frameon(original_frameon) + if transparent: for ax, cc in zip(self.axes, original_axes_colors): ax.patch.set_facecolor(cc[0]) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index b19c050b7381..721f10bcf5d9 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -658,6 +658,7 @@ def __call__(self, s): 'figure.dpi': [80, validate_float], # DPI 'figure.facecolor': ['0.75', validate_color], # facecolor; scalar gray 'figure.edgecolor': ['w', validate_color], # edgecolor; white + 'figure.frameon': [True, validate_bool], 'figure.autolayout': [False, validate_bool], 'figure.subplot.left': [0.125, ValidateInterval(0, 1, closedmin=True, @@ -677,6 +678,7 @@ def __call__(self, s): 'savefig.dpi': [100, validate_float], # DPI 'savefig.facecolor': ['w', validate_color], # facecolor; white 'savefig.edgecolor': ['w', validate_color], # edgecolor; white + 'savefig.frameon': [True, validate_bool], 'savefig.orientation': ['portrait', validate_orientation], # edgecolor; #white # what to add to extensionless filenames From 9307d3a32a46176d1a7c8ccc9cd3e9ef9fb60398 Mon Sep 17 00:00:00 2001 From: Till Stensitzki Date: Mon, 1 Apr 2013 17:53:15 +0200 Subject: [PATCH 2/2] better doc as suggested. --- lib/matplotlib/figure.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 67911c358e0e..0bc2ebf1afeb 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1359,8 +1359,9 @@ def savefig(self, *args, **kwargs): original values upon exit of this function. *frameon*: - If *True*, the figure patch will be colored. Else the figure - background will be transparent. + If *True*, the figure patch will be colored, if *False*, the + figure background will be transparent. If not provided, the + rcParam 'savefig.frameon' will be used. *bbox_inches*: Bbox in inches. Only the given portion of the figure is pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy