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

Skip to content

Commit 9479900

Browse files
Same get_tightbbox cache logic for axes3d
1 parent 8d780a2 commit 9479900

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,12 @@ def get_tightbbox(self, renderer=None, *, for_layout_only=False):
677677
# docstring inherited
678678
if not self.get_visible():
679679
return
680+
681+
# We need to reset the ticks cache here - get_tightbbox() is called
682+
# during layout calculations (e.g., constrained_layout) outside of
683+
# draw(), and must always recalculate to reflect current state.
684+
self._clear_ticks_cache()
685+
680686
# We have to directly access the internal data structures
681687
# (and hope they are up to date) because at draw time we
682688
# shift the ticks and their labels around in (x, y) space
@@ -708,10 +714,7 @@ def get_tightbbox(self, renderer=None, *, for_layout_only=False):
708714

709715
ticks = ticks_to_draw
710716

711-
# Don't use cached values here - get_tightbbox() is called during
712-
# layout calculations (e.g., constrained_layout) outside of draw(),
713-
# and must always recalculate to reflect current state.
714-
bb_1, bb_2 = self._get_ticklabel_bboxes(ticks, renderer, _use_cache=False)
717+
bb_1, bb_2 = self._get_ticklabel_bboxes(ticks, renderer, _use_cache=True)
715718
other = []
716719

717720
if self.offsetText.get_visible() and self.offsetText.get_text():
@@ -722,6 +725,7 @@ def get_tightbbox(self, renderer=None, *, for_layout_only=False):
722725
self.label.get_text()):
723726
other.append(self.label.get_window_extent(renderer))
724727

728+
self._clear_ticks_cache()
725729
return mtransforms.Bbox.union([*bb_1, *bb_2, *other])
726730

727731
d_interval = _api.deprecated(

0 commit comments

Comments
 (0)