|
From: <lee...@us...> - 2009-11-04 17:53:31
|
Revision: 7937
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7937&view=rev
Author: leejjoon
Date: 2009-11-04 17:53:25 +0000 (Wed, 04 Nov 2009)
Log Message:
-----------
add bbox_extra_artists keyword for savefig
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 2009-11-04 17:30:12 UTC (rev 7936)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-11-04 17:53:25 UTC (rev 7937)
@@ -1536,11 +1536,26 @@
*edgecolor*
the edgecolor of the figure
- *orientation* '
+ *orientation*
landscape' | 'portrait' (not supported on all backends)
*format*
when set, forcibly set the file format to save to
+
+
+ *bbox_inches*
+ Bbox in inches. Only the given portion of the figure is
+ saved. If 'tight', try to figure out the tight bbox of
+ the figure.
+
+ *pad_inches*
+ Amount of padding around the figure when bbox_inches is
+ 'tight'.
+
+ *bbox_extra_artists*
+ A list of extra artists that will be considered when the
+ tight bbox is calculated.
+
"""
if format is None:
if cbook.is_string_like(filename):
@@ -1597,6 +1612,18 @@
**kwargs)
renderer = self.figure._cachedRenderer
bbox_inches = self.figure.get_tightbbox(renderer)
+
+ bb = [a.get_window_extent(renderer) for a in kwargs.pop("bbox_extra_artists", []) \
+ if a.get_visible()]
+ if bb:
+ _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0])
+
+ bbox_inches1 = TransformedBbox(_bbox,
+ Affine2D().scale(1./self.figure.dpi))
+
+ bbox_inches = Bbox.union([bbox_inches, bbox_inches1])
+
+
pad = kwargs.pop("pad_inches", 0.1)
bbox_inches = bbox_inches.padded(pad)
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2009-11-04 17:30:12 UTC (rev 7936)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2009-11-04 17:53:25 UTC (rev 7937)
@@ -1031,6 +1031,10 @@
Amount of padding around the figure when bbox_inches is
'tight'.
+ *bbox_extra_artists*:
+ A list of extra artists that will be considered when the
+ tight bbox is calculated.
+
"""
for key in ('dpi', 'facecolor', 'edgecolor'):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|