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

Class BboxTransform

lib/matplotlib/transforms.py:2585–2624  ·  view source on GitHub ↗

`BboxTransform` linearly transforms points from one `Bbox` to another.

Source from the content-addressed store, hash-verified

2583
2584
2585class BboxTransform(Affine2DBase):
2586 """
2587 `BboxTransform` linearly transforms points from one `Bbox` to another.
2588 """
2589
2590 is_separable = True
2591
2592 def __init__(self, boxin, boxout, **kwargs):
2593 """
2594 Create a new `BboxTransform` that linearly transforms
2595 points from *boxin* to *boxout*.
2596 """
2597 _api.check_isinstance(BboxBase, boxin=boxin, boxout=boxout)
2598
2599 super().__init__(**kwargs)
2600 self._boxin = boxin
2601 self._boxout = boxout
2602 self.set_children(boxin, boxout)
2603 self._mtx = None
2604 self._inverted = None
2605
2606 __str__ = _make_str_method("_boxin", "_boxout")
2607
2608 def get_matrix(self):
2609 # docstring inherited
2610 if self._invalid:
2611 inl, inb, inw, inh = self._boxin.bounds
2612 outl, outb, outw, outh = self._boxout.bounds
2613 x_scale = outw / inw
2614 y_scale = outh / inh
2615 if DEBUG and (x_scale == 0 or y_scale == 0):
2616 raise ValueError(
2617 "Transforming from or to a singular bounding box")
2618 self._mtx = np.array([[x_scale, 0.0, -inl*x_scale+outl],
2619 [ 0.0, y_scale, -inb*y_scale+outb],
2620 [ 0.0, 0.0, 1.0]],
2621 float)
2622 self._inverted = None
2623 self._invalid = 0
2624 return self._mtx
2625
2626
2627class BboxTransformTo(Affine2DBase):

Callers 1

get_cursor_dataMethod · 0.90

Calls 1

_make_str_methodFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…