-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove duplicated computations in Axes.get_tightbbox. #16309
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
Conversation
We previously called _update_title_position and ax.get_window_extent twice. Don't do that. Small additional cleanups.
@@ -4388,18 +4387,13 @@ def get_tightbbox(self, renderer, call_axes_locator=True, | |||
bb.append(bb_yaxis) | |||
|
|||
self._update_title_position(renderer) | |||
|
|||
axbbox = self.get_window_extent(renderer) | |||
bb.append(axbbox) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this already adds self.get_window_extent(), so we don't need to add it again below.
This might be OK, but you should be sure to test by resizing a window... |
What case are you worried about? |
Constrained_layout needs to be called a couple of times, the first time gets everything close, but you need the second call because if you change the size of the axes the tick labels can change. Wasn't sure if something similar is needed here. |
I mean, sure I can do interactive tests, but I have no intuition what kind of setup/plots could trigger buggy behavior where the duplicate call is needed. |
One on the border of 7 ticks versus 6 or where the number of decimal places in the ticks will change? I know thats vague. But looking at this more carefully, its calling getting the extent twice in the same loop, so I agree thats redundant. |
bb.append(self._right_title.get_window_extent(renderer)) | ||
|
||
bb.append(self.get_window_extent(renderer)) | ||
for title in [self.title, self._left_title, self._right_title]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could extend bb with a list comprehension, if you‘re up to it.
We previously called _update_title_position and ax.get_window_extent
twice. Don't do that.
(I labeled this as "performance" even though I doubt it is really significant.)
Small additional cleanups.
PR Summary
PR Checklist