diff --git a/lib/matplotlib/tight_bbox.py b/lib/matplotlib/tight_bbox.py index 5904ebc1fa1c..bd58833baf88 100644 --- a/lib/matplotlib/tight_bbox.py +++ b/lib/matplotlib/tight_bbox.py @@ -57,11 +57,9 @@ def restore_bbox(): tr = Affine2D().scale(fixed_dpi) dpi_scale = fixed_dpi / fig.dpi - _bbox = TransformedBbox(bbox_inches, tr) - fig.bbox_inches = Bbox.from_bounds(0, 0, bbox_inches.width, bbox_inches.height) - x0, y0 = _bbox.x0, _bbox.y0 + x0, y0 = tr.transform(bbox_inches.p0) w1, h1 = fig.bbox.width * dpi_scale, fig.bbox.height * dpi_scale fig.transFigure._boxout = Bbox.from_bounds(-x0, -y0, w1, h1) fig.transFigure.invalidate() diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 809b970915a9..66283c7d7348 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -13,7 +13,7 @@ from matplotlib import _api, rcParams from matplotlib.font_manager import FontProperties -from matplotlib.transforms import TransformedBbox, Bbox +from matplotlib.transforms import Bbox def _auto_adjust_subplotpars( @@ -84,8 +84,7 @@ def _auto_adjust_subplotpars( bb += [ax.get_tightbbox(renderer)] tight_bbox_raw = Bbox.union(bb) - tight_bbox = TransformedBbox(tight_bbox_raw, - fig.transFigure.inverted()) + tight_bbox = fig.transFigure.inverted().transform_bbox(tight_bbox_raw) hspaces[rowspan, colspan.start] += ax_bbox.xmin - tight_bbox.xmin # l hspaces[rowspan, colspan.stop] += tight_bbox.xmax - ax_bbox.xmax # r diff --git a/lib/mpl_toolkits/axes_grid1/inset_locator.py b/lib/mpl_toolkits/axes_grid1/inset_locator.py index 5193cc540c31..fcdb32851b8c 100644 --- a/lib/mpl_toolkits/axes_grid1/inset_locator.py +++ b/lib/mpl_toolkits/axes_grid1/inset_locator.py @@ -126,7 +126,7 @@ def __init__(self, parent_axes, zoom, loc, bbox_transform=bbox_transform) def get_extent(self, renderer): - bb = TransformedBbox(self.axes.viewLim, self.parent_axes.transData) + bb = self.parent_axes.transData.transform_bbox(self.axes.viewLim) fontsize = renderer.points_to_pixels(self.prop.get_size_in_points()) pad = self.pad * fontsize return (abs(bb.width * self.zoom) + 2 * pad,