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

Skip to content

Commit 9c4479a

Browse files
committed
Small simplifications to BboxImage.
self._transform/get_transform() can just be inherited from the base Artist class. A BboxTransform starting at the unit bbox is equivalent to BboxTransformTo.
1 parent ae47ad2 commit 9c4479a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/matplotlib/image.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
# For user convenience, the names from _image are also imported into
2525
# the image namespace:
2626
from matplotlib._image import *
27-
from matplotlib.transforms import (Affine2D, BboxBase, Bbox, BboxTransform,
28-
IdentityTransform, TransformedBbox)
27+
from matplotlib.transforms import (
28+
Affine2D, BboxBase, Bbox, BboxTransform, BboxTransformTo,
29+
IdentityTransform, TransformedBbox)
2930

3031
_log = logging.getLogger(__name__)
3132

@@ -1377,12 +1378,7 @@ def __init__(self, bbox,
13771378
resample=resample,
13781379
**kwargs
13791380
)
1380-
13811381
self.bbox = bbox
1382-
self._transform = IdentityTransform()
1383-
1384-
def get_transform(self):
1385-
return self._transform
13861382

13871383
def get_window_extent(self, renderer=None):
13881384
if renderer is None:
@@ -1416,7 +1412,7 @@ def make_image(self, renderer, magnification=1.0, unsampled=False):
14161412
bbox_in._points /= [width, height]
14171413
bbox_out = self.get_window_extent(renderer)
14181414
clip = Bbox([[0, 0], [width, height]])
1419-
self._transform = BboxTransform(Bbox([[0, 0], [1, 1]]), clip)
1415+
self._transform = BboxTransformTo(clip)
14201416
return self._make_image(
14211417
self._A,
14221418
bbox_in, bbox_out, clip, magnification, unsampled=unsampled)

0 commit comments

Comments
 (0)