Revision: 8649 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8649&view=rev Author: mdboom Date: 2010-08-18 17:00:29 +0000 (Wed, 18 Aug 2010)
Log Message: ----------- Fix positions of r axis labels when rmin != 0.0 in polar plots. Modified Paths: -------------- branches/v1_0_maint/lib/matplotlib/projections/polar.py branches/v1_0_maint/lib/matplotlib/transforms.py Modified: branches/v1_0_maint/lib/matplotlib/projections/polar.py =================================================================== --- branches/v1_0_maint/lib/matplotlib/projections/polar.py 2010-08-18 16:09:19 UTC (rev 8648) +++ branches/v1_0_maint/lib/matplotlib/projections/polar.py 2010-08-18 17:00:29 UTC (rev 8649) @@ -14,7 +14,7 @@ from matplotlib.ticker import Formatter, Locator, FormatStrFormatter from matplotlib.transforms import Affine2D, Affine2DBase, Bbox, \ BboxTransformTo, IdentityTransform, Transform, TransformWrapper, \ - ScaledTranslation, blended_transform_factory + ScaledTranslation, blended_transform_factory, BboxTransformToMaxOnly import matplotlib.spines as mspines class PolarAxes(Axes): @@ -41,16 +41,16 @@ self._axis = axis def transform(self, tr): - xy = np.zeros(tr.shape, np.float_) + xy = np.empty(tr.shape, np.float_) if self._axis is not None: rmin = self._axis.viewLim.ymin else: rmin = 0 - t = tr[:, 0:1] - r = tr[:, 1:2] - x = xy[:, 0:1] - y = xy[:, 1:2] + t = tr[:, 0:1] + r = tr[:, 1:2] + x = xy[:, 0:1] + y = xy[:, 1:2] if rmin != 0: r = r - rmin @@ -188,7 +188,7 @@ def view_limits(self, vmin, vmax): vmin, vmax = self.base.view_limits(vmin, vmax) - return 0, vmax + return vmin, vmax def __init__(self, *args, **kwargs): @@ -290,7 +290,8 @@ # The r-axis labels are put at an angle and padded in the r-direction self._r_label1_position = ScaledTranslation( 22.5, self._rpad, - blended_transform_factory(Affine2D(), BboxTransformTo(self.viewLim))) + blended_transform_factory( + Affine2D(), BboxTransformToMaxOnly(self.viewLim))) self._yaxis_text1_transform = ( self._r_label1_position + Affine2D().scale(1.0 / 360.0, 1.0) + @@ -298,7 +299,8 @@ ) self._r_label2_position = ScaledTranslation( 22.5, -self._rpad, - blended_transform_factory(Affine2D(), BboxTransformTo(self.viewLim))) + blended_transform_factory( + Affine2D(), BboxTransformToMaxOnly(self.viewLim))) self._yaxis_text2_transform = ( self._r_label2_position + Affine2D().scale(1.0 / 360.0, 1.0) + Modified: branches/v1_0_maint/lib/matplotlib/transforms.py =================================================================== --- branches/v1_0_maint/lib/matplotlib/transforms.py 2010-08-18 16:09:19 UTC (rev 8648) +++ branches/v1_0_maint/lib/matplotlib/transforms.py 2010-08-18 17:00:29 UTC (rev 8649) @@ -2107,6 +2107,31 @@ get_matrix.__doc__ = Affine2DBase.get_matrix.__doc__ +class BboxTransformToMaxOnly(BboxTransformTo): + """ + :class:`BboxTransformTo` is a transformation that linearly + transforms points from the unit bounding box to a given + :class:`Bbox` with a fixed upper left of (0, 0). + """ + def __repr__(self): + return "BboxTransformToMaxOnly(%s)" % (self._boxout) + __str__ = __repr__ + + def get_matrix(self): + if self._invalid: + xmax, ymax = self._boxout.max + if DEBUG and (xmax == 0 or ymax == 0): + raise ValueError("Transforming to a singular bounding box.") + self._mtx = np.array([[xmax, 0.0, 0.0], + [ 0.0, ymax, 0.0], + [ 0.0, 0.0, 1.0]], + np.float_) + self._inverted = None + self._invalid = 0 + return self._mtx + get_matrix.__doc__ = Affine2DBase.get_matrix.__doc__ + + class BboxTransformFrom(Affine2DBase): """ :class:`BboxTransformFrom` linearly transforms points from a given This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins