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

Class Affine2D

lib/matplotlib/transforms.py:1941–2160  ·  view source on GitHub ↗

A mutable 2D affine transformation.

Source from the content-addressed store, hash-verified

1939
1940
1941class Affine2D(Affine2DBase):
1942 """
1943 A mutable 2D affine transformation.
1944 """
1945
1946 def __init__(self, matrix=None, **kwargs):
1947 """
1948 Initialize an Affine transform from a 3x3 numpy float array::
1949
1950 a c e
1951 b d f
1952 0 0 1
1953
1954 If *matrix* is None, initialize with the identity transform.
1955 """
1956 super().__init__(**kwargs)
1957 if matrix is None:
1958 # A bit faster than np.identity(3).
1959 matrix = IdentityTransform._mtx
1960 self._mtx = matrix.copy()
1961 self._invalid = 0
1962
1963 _base_str = _make_str_method("_mtx")
1964
1965 def __str__(self):
1966 return (self._base_str()
1967 if (self._mtx != np.diag(np.diag(self._mtx))).any()
1968 else f"Affine2D().scale({self._mtx[0, 0]}, {self._mtx[1, 1]})"
1969 if self._mtx[0, 0] != self._mtx[1, 1]
1970 else f"Affine2D().scale({self._mtx[0, 0]})")
1971
1972 @staticmethod
1973 def from_values(a, b, c, d, e, f):
1974 """
1975 Create a new Affine2D instance from the given values::
1976
1977 a c e
1978 b d f
1979 0 0 1
1980
1981 .
1982 """
1983 return Affine2D(
1984 np.array([a, c, e, b, d, f, 0.0, 0.0, 1.0], float).reshape((3, 3)))
1985
1986 def get_matrix(self):
1987 """
1988 Get the underlying transformation matrix as a 3x3 array::
1989
1990 a c e
1991 b d f
1992 0 0 1
1993
1994 .
1995 """
1996 if self._invalid:
1997 self._inverted = None
1998 self._invalid = 0

Callers 15

drawMethod · 0.90
drawMethod · 0.90
get_window_extentMethod · 0.90
__init__Method · 0.90
test_polar_boxFunction · 0.90
test_axis_directionFunction · 0.90
composite_imagesFunction · 0.90
_resampleFunction · 0.90
_make_imageMethod · 0.90

Calls 1

_make_str_methodFunction · 0.85

Tested by 15

test_polar_boxFunction · 0.72
test_axis_directionFunction · 0.72
test_marker_scaledFunction · 0.72
test_alt_transformFunction · 0.72
test_cursor_dataFunction · 0.72
test_rotate_imageFunction · 0.72
test_resample_nonaffineFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…