MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / rotate

Method rotate

lib/matplotlib/transforms.py:2032–2053  ·  view source on GitHub ↗

Add a rotation (in radians) to this transform in place. Returns *self*, so this method can easily be chained with more calls to :meth:`rotate`, :meth:`rotate_deg`, :meth:`translate` and :meth:`scale`.

(self, theta)

Source from the content-addressed store, hash-verified

2030 return self
2031
2032 def rotate(self, theta):
2033 """
2034 Add a rotation (in radians) to this transform in place.
2035
2036 Returns *self*, so this method can easily be chained with more
2037 calls to :meth:`rotate`, :meth:`rotate_deg`, :meth:`translate`
2038 and :meth:`scale`.
2039 """
2040 a = math.cos(theta)
2041 b = math.sin(theta)
2042 mtx = self._mtx
2043 # Operating and assigning one scalar at a time is much faster.
2044 (xx, xy, x0), (yx, yy, y0), _ = mtx.tolist()
2045 # mtx = [[a -b 0], [b a 0], [0 0 1]] * mtx
2046 mtx[0, 0] = a * xx - b * yx
2047 mtx[0, 1] = a * xy - b * yy
2048 mtx[0, 2] = a * x0 - b * y0
2049 mtx[1, 0] = b * xx + a * yx
2050 mtx[1, 1] = b * xy + a * yy
2051 mtx[1, 2] = b * x0 + a * y0
2052 self.invalidate()
2053 return self
2054
2055 def rotate_deg(self, degrees):
2056 """

Callers 15

rotate_degMethod · 0.95
test_uses_per_pathFunction · 0.95
test_transformed_pathFunction · 0.95
_rotateFunction · 0.45
rotatedMethod · 0.45
rotate_aroundMethod · 0.45
get_matrixMethod · 0.45
rotatedMethod · 0.45
get_patch_transformMethod · 0.45
set_dataMethod · 0.45
drawMethod · 0.45

Calls 1

invalidateMethod · 0.45

Tested by 6

test_uses_per_pathFunction · 0.76
test_transformed_pathFunction · 0.76
test_path_intersect_pathFunction · 0.36
test_cursor_dataFunction · 0.36
test_rotateMethod · 0.36
setup_methodMethod · 0.36