|
31 | 31 | import matplotlib.tri as mtri |
32 | 32 | import matplotlib.units as munits |
33 | 33 | from matplotlib import _preprocess_data, rcParams |
34 | | -from matplotlib.axes._base import _AxesBase, _process_plot_format |
| 34 | +from matplotlib.axes._base import ( |
| 35 | + _AxesBase, _TransformedBoundsLocator, _process_plot_format) |
35 | 36 | from matplotlib.axes._secondary_axes import SecondaryAxis |
36 | 37 | from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer |
37 | 38 |
|
38 | 39 | _log = logging.getLogger(__name__) |
39 | 40 |
|
40 | 41 |
|
41 | | -class _InsetLocator: |
42 | | - """ |
43 | | - Axes locator for `.Axes.inset_axes`. |
44 | | -
|
45 | | - The locater is a callable object used in `.Axes.set_aspect` to compute the |
46 | | - axes location depending on the renderer. |
47 | | - """ |
48 | | - |
49 | | - def __init__(self, bounds, transform): |
50 | | - """ |
51 | | - *bounds* (a ``[l, b, w, h]`` rectangle) and *transform* together |
52 | | - specify the position of the inset axes. |
53 | | - """ |
54 | | - self._bounds = bounds |
55 | | - self._transform = transform |
56 | | - |
57 | | - def __call__(self, ax, renderer): |
58 | | - # Subtracting transFigure will typically rely on inverted(), freezing |
59 | | - # the transform; thus, this needs to be delayed until draw time as |
60 | | - # transFigure may otherwise change after this is evaluated. |
61 | | - return mtransforms.TransformedBbox( |
62 | | - mtransforms.Bbox.from_bounds(*self._bounds), |
63 | | - self._transform - ax.figure.transFigure) |
64 | | - |
65 | | - |
66 | 42 | # The axes module contains all the wrappers to plotting functions. |
67 | 43 | # All the other methods should go in the _AxesBase class. |
68 | 44 |
|
@@ -365,7 +341,7 @@ def inset_axes(self, bounds, *, transform=None, zorder=5, **kwargs): |
365 | 341 | kwargs.setdefault('label', 'inset_axes') |
366 | 342 |
|
367 | 343 | # This puts the rectangle into figure-relative coordinates. |
368 | | - inset_locator = _InsetLocator(bounds, transform) |
| 344 | + inset_locator = _TransformedBoundsLocator(bounds, transform) |
369 | 345 | bounds = inset_locator(self, None).bounds |
370 | 346 | inset_ax = Axes(self.figure, bounds, zorder=zorder, **kwargs) |
371 | 347 | # this locator lets the axes move if in data coordinates. |
|
0 commit comments