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

Skip to content

Commit 3ee0219

Browse files
authored
Merge pull request #16309 from anntzer/doubletight
PRF: Remove duplicated computations in Axes.get_tightbbox.
2 parents d162b6d + e5daa3b commit 3ee0219

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,7 +4363,6 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
43634363
matplotlib.axes.Axes.get_window_extent
43644364
matplotlib.axis.Axis.get_tightbbox
43654365
matplotlib.spines.Spine.get_window_extent
4366-
43674366
"""
43684367

43694368
bb = []
@@ -4388,18 +4387,13 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
43884387
bb.append(bb_yaxis)
43894388

43904389
self._update_title_position(renderer)
4390+
43914391
axbbox = self.get_window_extent(renderer)
43924392
bb.append(axbbox)
43934393

4394-
self._update_title_position(renderer)
4395-
if self.title.get_visible():
4396-
bb.append(self.title.get_window_extent(renderer))
4397-
if self._left_title.get_visible():
4398-
bb.append(self._left_title.get_window_extent(renderer))
4399-
if self._right_title.get_visible():
4400-
bb.append(self._right_title.get_window_extent(renderer))
4401-
4402-
bb.append(self.get_window_extent(renderer))
4394+
for title in [self.title, self._left_title, self._right_title]:
4395+
if title.get_visible():
4396+
bb.append(title.get_window_extent(renderer))
44034397

44044398
bbox_artists = bbox_extra_artists
44054399
if bbox_artists is None:
@@ -4422,10 +4416,9 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
44224416
and 0 < bbox.width < np.inf
44234417
and 0 < bbox.height < np.inf):
44244418
bb.append(bbox)
4425-
_bbox = mtransforms.Bbox.union(
4426-
[b for b in bb if b.width != 0 or b.height != 0])
44274419

4428-
return _bbox
4420+
return mtransforms.Bbox.union(
4421+
[b for b in bb if b.width != 0 or b.height != 0])
44294422

44304423
def _make_twin_axes(self, *args, **kwargs):
44314424
"""Make a twinx axes of self. This is used for twinx and twiny."""

0 commit comments

Comments
 (0)