Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81b659c

Browse files
committed
Merged revisions 8649-8650 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint ........ r8649 | mdboom | 2010-08-18 13:00:29 -0400 (Wed, 18 Aug 2010) | 2 lines Fix positions of r axis labels when rmin != 0.0 in polar plots. ........ r8650 | mdboom | 2010-08-18 13:35:26 -0400 (Wed, 18 Aug 2010) | 2 lines Fix unit tests for polar rmin changes in last commit. ........ svn path=/trunk/matplotlib/; revision=8651
1 parent 3525391 commit 81b659c

5 files changed

Lines changed: 45 additions & 18 deletions

File tree

lib/matplotlib/projections/polar.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from matplotlib.ticker import Formatter, Locator, FormatStrFormatter
1515
from matplotlib.transforms import Affine2D, Affine2DBase, Bbox, \
1616
BboxTransformTo, IdentityTransform, Transform, TransformWrapper, \
17-
ScaledTranslation, blended_transform_factory
17+
ScaledTranslation, blended_transform_factory, BboxTransformToMaxOnly
1818
import matplotlib.spines as mspines
1919

2020
class PolarAxes(Axes):
@@ -41,16 +41,16 @@ def __init__(self, axis=None):
4141
self._axis = axis
4242

4343
def transform(self, tr):
44-
xy = np.zeros(tr.shape, np.float_)
44+
xy = np.empty(tr.shape, np.float_)
4545
if self._axis is not None:
4646
rmin = self._axis.viewLim.ymin
4747
else:
4848
rmin = 0
4949

50-
t = tr[:, 0:1]
51-
r = tr[:, 1:2]
52-
x = xy[:, 0:1]
53-
y = xy[:, 1:2]
50+
t = tr[:, 0:1]
51+
r = tr[:, 1:2]
52+
x = xy[:, 0:1]
53+
y = xy[:, 1:2]
5454

5555
if rmin != 0:
5656
r = r - rmin
@@ -291,15 +291,17 @@ def _set_lim_and_transforms(self):
291291
# The r-axis labels are put at an angle and padded in the r-direction
292292
self._r_label1_position = ScaledTranslation(
293293
22.5, self._rpad,
294-
blended_transform_factory(Affine2D(), BboxTransformTo(self.viewLim)))
294+
blended_transform_factory(
295+
Affine2D(), BboxTransformToMaxOnly(self.viewLim)))
295296
self._yaxis_text1_transform = (
296297
self._r_label1_position +
297298
Affine2D().scale(1.0 / 360.0, 1.0) +
298299
self._yaxis_transform
299300
)
300301
self._r_label2_position = ScaledTranslation(
301302
22.5, -self._rpad,
302-
blended_transform_factory(Affine2D(), BboxTransformTo(self.viewLim)))
303+
blended_transform_factory(
304+
Affine2D(), BboxTransformToMaxOnly(self.viewLim)))
303305
self._yaxis_text2_transform = (
304306
self._r_label2_position +
305307
Affine2D().scale(1.0 / 360.0, 1.0) +
3 Bytes
Binary file not shown.
269 Bytes
Loading

lib/matplotlib/tests/baseline_images/test_axes/polar_rmin.svg

Lines changed: 10 additions & 10 deletions
Loading

lib/matplotlib/transforms.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,31 @@ def get_matrix(self):
21072107
get_matrix.__doc__ = Affine2DBase.get_matrix.__doc__
21082108

21092109

2110+
class BboxTransformToMaxOnly(BboxTransformTo):
2111+
"""
2112+
:class:`BboxTransformTo` is a transformation that linearly
2113+
transforms points from the unit bounding box to a given
2114+
:class:`Bbox` with a fixed upper left of (0, 0).
2115+
"""
2116+
def __repr__(self):
2117+
return "BboxTransformToMaxOnly(%s)" % (self._boxout)
2118+
__str__ = __repr__
2119+
2120+
def get_matrix(self):
2121+
if self._invalid:
2122+
xmax, ymax = self._boxout.max
2123+
if DEBUG and (xmax == 0 or ymax == 0):
2124+
raise ValueError("Transforming to a singular bounding box.")
2125+
self._mtx = np.array([[xmax, 0.0, 0.0],
2126+
[ 0.0, ymax, 0.0],
2127+
[ 0.0, 0.0, 1.0]],
2128+
np.float_)
2129+
self._inverted = None
2130+
self._invalid = 0
2131+
return self._mtx
2132+
get_matrix.__doc__ = Affine2DBase.get_matrix.__doc__
2133+
2134+
21102135
class BboxTransformFrom(Affine2DBase):
21112136
"""
21122137
:class:`BboxTransformFrom` linearly transforms points from a given

0 commit comments

Comments
 (0)