8000 Change skew() angle definitions. · matplotlib/matplotlib@c3a721b · GitHub
[go: up one dir, main page]

Skip to content

Commit c3a721b

Browse files
committed
Change skew() angle definitions.
Instead of specifying the angles as rotations of the axes, it is easier (and more standard) to think of the angles in the skew transform as shearing angles along each axis. Doing so means the X and Y angles are swapped from how they were used before, so this commit also updates the example.
1 parent 674302b commit c3a721b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

examples/api/skewt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _set_lim_and_transforms(self):
131131
# We keep the pre-transAxes transform around for other users, like the
132132
# spines for finding bounds
133133
self.transDataToAxes = self.transScale + (self.transLimits +
134-
transforms.Affine2D().skew_deg(0, rot))
134+
transforms.Affine2D().skew_deg(rot, 0))
135135

136136
# Create the full transform from Data to Pixels
137137
self.transData = self.transDataToAxes + self.transAxes
@@ -141,7 +141,7 @@ def _set_lim_and_transforms(self):
141141
self._xaxis_transform = (transforms.blended_transform_factory(
142142
self.transScale + self.transLimits,
143143
transforms.IdentityTransform()) +
144-
transforms.Affine2D().skew_deg(0, rot)) + self.transAxes
144+
transforms.Affine2D().skew_deg(rot, 0)) + self.transAxes
145145

146146
# Now register the projection with matplotlib so the user can select
147147
# it.

lib/matplotlib/transforms.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,38 +1876,38 @@ def scale(self, sx, sy=None):
18761876
self.invalidate()
18771877
return self
18781878

1879-
def skew(self, xAxisRot, yAxisRot):
1879+
def skew(self, xShear, yShear):
18801880
"""
18811881
Adds a skew in place.
18821882
1883-
*xAxisRot* and *yAxisRot* are the rotations of the *x*- and
1883+
*xShear* and *yShear* are the shear angles along the *x*- and
18841884
*y*-axes, respectively, in radians.
18851885
18861886
Returns *self*, so this method can easily be chained with more
18871887
calls to :meth:`rotate`, :meth:`rotate_deg`, :meth:`translate`
18881888
and :meth:`scale`.
18891889
"""
1890-
rotX = np.tan(xAxisRot)
1891-
rotY = np.tan(yAxisRot)
1890+
rotX = np.tan(xShear)
1891+
rotY = np.tan(yShear)
18921892
skew_mtx = np.array(
1893-
[[1.0, rotY, 0.0], [rotX, 1.0, 0.0], [0.0, 0.0, 1.0]],
1893+
[[1.0, rotX, 0.0], [rotY, 1.0, 0.0], [0.0, 0.0, 1.0]],
18941894
np.float_)
18951895
self._mtx = np.dot(skew_mtx, self._mtx)
18961896
self.invalidate()
18971897
return self
18981898

1899-
def skew_deg(self, xAxisRot, yAxisRot):
1899+
def skew_deg(self, xShear, yShear):
19001900
"""
19011901
Adds a skew in place.
19021902
1903-
*xAxisRot* and *yAxisRot* are the rotations of the *x*- and
1903+
*xShear* and *yShear* are the shear angles along the *x*- and
19041904
*y*-axes, respectively, in degrees.
19051905
19061906
Returns *self*, so this method can easily be chained with more
19071907
calls to :meth:`rotate`, :meth:`rotate_deg`, :meth:`translate`
19081908
and :meth:`scale`.
19091909
"""
1910-
return self.skew(np.deg2rad(xAxisRot), np.deg2rad(yAxisRot))
1910+
return self.skew(np.deg2rad(xShear), np.deg2rad(yShear))
19111911

19121912
def _get_is_separable(self):
19131913
mtx = self.get_matrix()

0 commit comments

Comments
 (0)
0