|
From: <ef...@us...> - 2010-04-28 19:17:23
|
Revision: 8282
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8282&view=rev
Author: efiring
Date: 2010-04-28 19:17:17 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
savefig: make the "transparent" kwarg work as advertised
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-04-28 18:14:06 UTC (rev 8281)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-04-28 19:17:17 UTC (rev 8282)
@@ -868,7 +868,7 @@
Backends need to implement a few specific methods in order to use their
own timing mechanisms so that the timer events are integrated into their
event loops.
-
+
Mandatory functions that must be implemented:
* _timer_start: Contains backend-specific code for starting the timer
* _timer_stop: Contains backend-specific code for stopping the timer
@@ -883,7 +883,7 @@
* _on_timer: This is the internal function that any timer object should
call, which will handle the task of running all callbacks that have
been set.
-
+
Attributes:
* interval: The time between timer events in milliseconds. Default
is 1000 ms.
@@ -1938,9 +1938,9 @@
Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
This is useful for getting periodic events through the backend's native
event loop. Implemented only for backends with GUIs.
-
+
optional arguments:
-
+
*interval*
Timer interval in milliseconds
*callbacks*
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2010-04-28 18:14:06 UTC (rev 8281)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2010-04-28 19:17:17 UTC (rev 8282)
@@ -1040,8 +1040,10 @@
backend. Most backends support png, pdf, ps, eps and svg.
*transparent*:
- If *True*, the figure patch and axes patches will all be
- transparent. This is useful, for example, for displaying
+ If *True*, the axes patches will all be transparent; the
+ figure patch will also be transparent unless facecolor
+ and/or edgecolor are specified via kwargs.
+ This is useful, for example, for displaying
a plot on top of a colored background on a web page. The
transparency of these patches will be restored to their
original values upon exit of this function.
@@ -1061,9 +1063,7 @@
"""
- for key in ('dpi', 'facecolor', 'edgecolor'):
- if key not in kwargs:
- kwargs[key] = rcParams['savefig.%s'%key]
+ kwargs.setdefault('dpi', rcParams['savefig.dpi'])
extension = rcParams['savefig.extension']
if args and is_string_like(args[0]) and '.' not in args[0] and extension != 'auto':
@@ -1072,20 +1072,25 @@
transparent = kwargs.pop('transparent', False)
if transparent:
- original_figure_alpha = self.patch.get_alpha()
- self.patch.set_alpha(0.0)
- original_axes_alpha = []
+ kwargs.setdefault('facecolor', 'none')
+ kwargs.setdefault('edgecolor', 'none')
+ original_axes_colors = []
for ax in self.axes:
patch = ax.patch
- original_axes_alpha.append(patch.get_alpha())
- patch.set_alpha(0.0)
+ original_axes_colors.append((patch.get_facecolor(),
+ patch.get_edgecolor()))
+ patch.set_facecolor('none')
+ patch.set_edgecolor('none')
+ else:
+ kwargs.setdefault('facecolor', rcParams['savefig.facecolor'])
+ kwargs.setdefault('edgecolor', rcParams['savefig.edgecolor'])
self.canvas.print_figure(*args, **kwargs)
if transparent:
- self.patch.set_alpha(original_figure_alpha)
- for ax, alpha in zip(self.axes, original_axes_alpha):
- ax.patch.set_alpha(alpha)
+ for ax, cc in zip(self.axes, original_axes_colors):
+ ax.patch.set_facecolor(cc[0])
+ ax.patch.set_edgecolor(cc[1])
@docstring.dedent_interpd
def colorbar(self, mappable, cax=None, ax=None, **kw):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|