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

Skip to content

Commit 87bae58

Browse files
authored
Merge pull request #21010 from anntzer/ntb
Avoid TransformedBbox where unneeded.
2 parents 39c5302 + 308d2ac commit 87bae58

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

lib/matplotlib/tight_bbox.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ def restore_bbox():
5757
tr = Affine2D().scale(fixed_dpi)
5858
dpi_scale = fixed_dpi / fig.dpi
5959

60-
_bbox = TransformedBbox(bbox_inches, tr)
61-
6260
fig.bbox_inches = Bbox.from_bounds(0, 0,
6361
bbox_inches.width, bbox_inches.height)
64-
x0, y0 = _bbox.x0, _bbox.y0
62+
x0, y0 = tr.transform(bbox_inches.p0)
6563
w1, h1 = fig.bbox.width * dpi_scale, fig.bbox.height * dpi_scale
6664
fig.transFigure._boxout = Bbox.from_bounds(-x0, -y0, w1, h1)
6765
fig.transFigure.invalidate()

lib/matplotlib/tight_layout.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from matplotlib import _api, rcParams
1515
from matplotlib.font_manager import FontProperties
16-
from matplotlib.transforms import TransformedBbox, Bbox
16+
from matplotlib.transforms import Bbox
1717

1818

1919
def _auto_adjust_subplotpars(
@@ -84,8 +84,7 @@ def _auto_adjust_subplotpars(
8484
bb += [ax.get_tightbbox(renderer)]
8585

8686
tight_bbox_raw = Bbox.union(bb)
87-
tight_bbox = TransformedBbox(tight_bbox_raw,
88-
fig.transFigure.inverted())
87+
tight_bbox = fig.transFigure.inverted().transform_bbox(tight_bbox_raw)
8988

9089
hspaces[rowspan, colspan.start] += ax_bbox.xmin - tight_bbox.xmin # l
9190
hspaces[rowspan, colspan.stop] += tight_bbox.xmax - ax_bbox.xmax # r

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(self, parent_axes, zoom, loc,
126126
bbox_transform=bbox_transform)
127127

128128
def get_extent(self, renderer):
129-
bb = TransformedBbox(self.axes.viewLim, self.parent_axes.transData)
129+
bb = self.parent_axes.transData.transform_bbox(self.axes.viewLim)
130130
fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
131131
pad = self.pad * fontsize
132132
return (abs(bb.width * self.zoom) + 2 * pad,

0 commit comments

Comments
 (0)