Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
MNT: Don't require renderer for window_extent and tightbbox#22745
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
No need to specify renderer for get_tightbbox and get_window_extent | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
The ``get_tightbbox`` and `~.Artist.get_window_extent` methods | ||
no longer require the *renderer* kwarg, saving users from having to | ||
querry it from ``fig.canvas.get_renderer``. If the *renderer* | ||
kwarg is not supplied these methods first check if there is a cached renderer | ||
from a previous draw and use that. If there is no cahched renderer, then | ||
the methods will use ``fig.canvas.get_renderer()`` as a fallback. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1198,14 +1198,16 @@ def _update_ticks(self): | ||
return ticks_to_draw | ||
def _get_ticklabel_bboxes(self, ticks, renderer=None): | ||
"""Return lists of bboxes for ticks' label1's and label2's.""" | ||
if renderer is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't think you need to normalize here; just let the labels do it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That depends not he strategy we want to employ - it could wait to normalize until the end, but this does save a bunch of calls to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Fair. | ||
renderer = self.figure._get_renderer() | ||
return ([tick.label1.get_window_extent(renderer) | ||
for tick in ticks if tick.label1.get_visible()], | ||
[tick.label2.get_window_extent(renderer) | ||
for tick in ticks if tick.label2.get_visible()]) | ||
def get_tightbbox(self, renderer=None, *, for_layout_only=False): | ||
""" | ||
Return a bounding box that encloses the axis. It only accounts | ||
tick labels, axis label, and offsetText. | ||
@@ -1217,7 +1219,8 @@ def get_tightbbox(self, renderer, *, for_layout_only=False): | ||
""" | ||
if not self.get_visible(): | ||
return | ||
if renderer is None: | ||
renderer = self.figure._get_renderer() | ||
ticks_to_draw = self._update_ticks() | ||
self._update_label_position(renderer) | ||
Uh oh!
There was an error while loading.Please reload this page.