diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 464105ecf3dc..15c457171295 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -1928,7 +1928,8 @@ def __init__(self, matrix=None, **kwargs): """ Affine2DBase.__init__(self, **kwargs) if matrix is None: - matrix = np.identity(3) + # A bit faster than np.identity(3). + matrix = IdentityTransform._mtx.copy() self._mtx = matrix self._invalid = 0 @@ -1999,13 +2000,14 @@ def identity(): Unless this transform will be mutated later on, consider using the faster :class:`IdentityTransform` class instead. """ - return Affine2D(np.identity(3)) + return Affine2D() def clear(self): """ Reset the underlying matrix to the identity transform. """ - self._mtx = np.identity(3) + # A bit faster than np.identity(3). + self._mtx = IdentityTransform._mtx.copy() self.invalidate() return self