Skip to content

Avoid TransformedBbox where unneeded. #21010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/matplotlib/tight_bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/tight_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down