SF.net SVN: matplotlib:[6937] trunk/matplotlib
Revision: 6937 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6937&view=rev Author: jouni Date: 2009-02-26 19:44:30 + (Thu, 26 Feb 2009) Log Message: --- Support image clipping in the pdf backend Modified Paths: -- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py Modified: trunk/matplotlib/CHANGELOG === --- trunk/matplotlib/CHANGELOG 2009-02-26 00:12:33 UTC (rev 6936) +++ trunk/matplotlib/CHANGELOG 2009-02-26 19:44:30 UTC (rev 6937) @@ -1,3 +1,5 @@ +2009-02-26 Support image clipping in pdf backend. - JKS + 2009-02-25 Improve tick location subset choice in FixedLocator. - EF 2009-02-24 Deprecate numerix, and strip out all but the numpy Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py === --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-02-26 00:12:33 UTC (rev 6936) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-02-26 19:44:30 UTC (rev 6937) @@ -39,7 +39,7 @@ from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \ LOAD_NO_HINTING, KERNING_UNFITTED from matplotlib.mathtext import MathTextParser -from matplotlib.transforms import Affine2D, Bbox, BboxBase +from matplotlib.transforms import Affine2D, Bbox, BboxBase, TransformedPath from matplotlib.path import Path from matplotlib import ttconv @@ -1268,10 +1268,12 @@ return self.image_dpi/72.0 def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): -# MGDTODO: Support clippath here gc = self.new_gc() if bbox is not None: gc.set_clip_rectangle(bbox) +if clippath is not None: +clippath = TransformedPath(clippath, clippath_trans) +gc.set_clip_path(clippath) self.check_gc(gc) h, w = im.get_size_out() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6938] branches/v0_98_5_maint
Revision: 6938 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6938&view=rev Author: jouni Date: 2009-02-26 19:54:48 + (Thu, 26 Feb 2009) Log Message: --- Support image clipping in the pdf backend Modified Paths: -- branches/v0_98_5_maint/CHANGELOG branches/v0_98_5_maint/lib/matplotlib/backends/backend_pdf.py Modified: branches/v0_98_5_maint/CHANGELOG === --- branches/v0_98_5_maint/CHANGELOG2009-02-26 19:44:30 UTC (rev 6937) +++ branches/v0_98_5_maint/CHANGELOG2009-02-26 19:54:48 UTC (rev 6938) @@ -1,3 +1,5 @@ +2009-02-26 Support image clipping in pdf backend. - JKS + 2009-02-16 Move plot_directive.py to the installed source tree. Add support for inline code content - MGD Modified: branches/v0_98_5_maint/lib/matplotlib/backends/backend_pdf.py === --- branches/v0_98_5_maint/lib/matplotlib/backends/backend_pdf.py 2009-02-26 19:44:30 UTC (rev 6937) +++ branches/v0_98_5_maint/lib/matplotlib/backends/backend_pdf.py 2009-02-26 19:54:48 UTC (rev 6938) @@ -39,7 +39,7 @@ from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \ LOAD_NO_HINTING, KERNING_UNFITTED from matplotlib.mathtext import MathTextParser -from matplotlib.transforms import Affine2D, Bbox, BboxBase +from matplotlib.transforms import Affine2D, Bbox, BboxBase, TransformedPath from matplotlib.path import Path from matplotlib import ttconv @@ -1235,10 +1235,12 @@ return self.image_dpi/72.0 def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): -# MGDTODO: Support clippath here gc = self.new_gc() if bbox is not None: gc.set_clip_rectangle(bbox) +if clippath is not None: +clippath = TransformedPath(clippath, clippath_trans) +gc.set_clip_path(clippath) self.check_gc(gc) h, w = im.get_size_out() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[6939] trunk/matplotlib
Revision: 6939
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6939&view=rev
Author: leejjoon
Date: 2009-02-26 20:12:38 + (Thu, 26 Feb 2009)
Log Message:
---
Add optional bbox_to_anchor argument for legend class
Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/pylab_examples/legend_demo3.py
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG 2009-02-26 19:54:48 UTC (rev 6938)
+++ trunk/matplotlib/CHANGELOG 2009-02-26 20:12:38 UTC (rev 6939)
@@ -1,3 +1,5 @@
+2009-02-26 Add optional bbox_to_anchor argument for legend class - JJL
+
2009-02-26 Support image clipping in pdf backend. - JKS
2009-02-25 Improve tick location subset choice in FixedLocator. - EF
Modified: trunk/matplotlib/examples/pylab_examples/legend_demo3.py
===
--- trunk/matplotlib/examples/pylab_examples/legend_demo3.py2009-02-26
19:54:48 UTC (rev 6938)
+++ trunk/matplotlib/examples/pylab_examples/legend_demo3.py2009-02-26
20:12:38 UTC (rev 6939)
@@ -3,7 +3,6 @@
matplotlib.rcParams['legend.fancybox'] = True
import matplotlib.pyplot as plt
import numpy as np
-import pylab
def myplot(ax):
t1 = np.arange(0.0, 1.0, 0.1)
@@ -18,7 +17,8 @@
ax2 = plt.subplot(3,1,2)
myplot(ax2)
-ax2.legend(loc=1, ncol=2, shadow=True, title="Legend")
+ax2.legend(loc="center left", bbox_to_anchor=[0.5, 0.5],
+ ncol=2, shadow=True, title="Legend")
ax2.get_legend().get_title().set_color("red")
ax3 = plt.subplot(3,1,3)
@@ -26,8 +26,6 @@
ax3.legend(loc=1, ncol=4, mode="expand", shadow=True)
-#title('Damped oscillation')
-
plt.draw()
plt.show()
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===
--- trunk/matplotlib/lib/matplotlib/legend.py 2009-02-26 19:54:48 UTC (rev
6938)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2009-02-26 20:12:38 UTC (rev
6939)
@@ -32,7 +32,7 @@
from matplotlib.lines import Line2D
from matplotlib.patches import Patch, Rectangle, Shadow, FancyBboxPatch
from matplotlib.collections import LineCollection, RegularPolyCollection
-from matplotlib.transforms import Bbox
+from matplotlib.transforms import Bbox, TransformedBbox, BboxTransformTo
from matplotlib.offsetbox import HPacker, VPacker, TextArea, DrawingArea
@@ -112,6 +112,7 @@
fancybox=None, # True use a fancy box, false use a rounded
box, none use rc
shadow = None,
title = None, # set a title for the legend
+ bbox_to_anchor = None, # bbox thaw the legend will be
anchored.
):
"""
- *parent* : the artist that contains the legend
@@ -137,6 +138,7 @@
borderaxespad the pad between the axes and legend border
columnspacing the spacing between columns
title the legend title
+bbox_to_anchor the bbox that the legend will be anchored.
==
The dimensions of pad and spacing are given as a fraction of the
@@ -249,7 +251,8 @@
self._loc = loc
self._mode = mode
-
+self.set_bbox_to_anchor(bbox_to_anchor)
+
# We use FancyBboxPatch to draw a legend frame. The location
# and size of the box will be updated during the drawing time.
self.legendPatch = FancyBboxPatch(
@@ -294,6 +297,7 @@
a.set_transform(self.get_transform())
+
def _findoffset_best(self, width, height, xdescent, ydescent, renderer):
"Heper function to locate the legend at its best position"
ox, oy = self._find_best_position(width, height, renderer)
@@ -305,11 +309,11 @@
if iterable(self._loc) and len(self._loc)==2:
# when loc is a tuple of axes(or figure) coordinates.
fx, fy = self._loc
-bbox = self.parent.bbox
+bbox = self.get_bbox_to_anchor()
x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy
else:
bbox = Bbox.from_bounds(0, 0, width, height)
-x, y = self._get_anchored_bbox(self._loc, bbox, self.parent.bbox,
renderer)
+x, y = self._get_anchored_bbox(self._loc, bbox,
self.get_bbox_to_anchor(), renderer)
return x+xdescent, y+ydescent
@@ -340,7 +344,7 @@
# width of the paret (minus pads)
if self._mode in ["expand"]:
pad = 2*(self.borderaxespad+self.borderpad)*fontsize
-self._legend_box.set_width(self.parent.bbox.width-pad)
+self._legend_box.set_width(self.get_bbox_to_anchor().width-pad)
if self._drawFrame:
# update the location and size of the legend
@@ -671,6 +675,48 @@
SF.net SVN: matplotlib:[6940] trunk/matplotlib/
Revision: 6940 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6940&view=rev Author: jouni Date: 2009-02-26 20:20:47 + (Thu, 26 Feb 2009) Log Message: --- Mark pdf backend fix as merged Property Changed: trunk/matplotlib/ Property changes on: trunk/matplotlib ___ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6934 + /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6938 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
