Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions 19 lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4363,7 +4363,6 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
matplotlib.axes.Axes.get_window_extent
matplotlib.axis.Axis.get_tightbbox
matplotlib.spines.Spine.get_window_extent

"""

bb = []
Expand All @@ -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)
Copy link
Contributor Author

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.


self._update_title_position(renderer)
if self.title.get_visible():
bb.append(self.title.get_window_extent(renderer))
if self._left_title.get_visible():
bb.append(self._left_title.get_window_extent(renderer))
if self._right_title.get_visible():
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]:
Copy link
Member

@timhoffm timhoffm Jan 24, 2020

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.

if title.get_visible():
bb.append(title.get_window_extent(renderer))

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

return _bbox
return mtransforms.Bbox.union(
[b for b in bb if b.width != 0 or b.height != 0])

def _make_twin_axes(self, *args, **kwargs):
"""Make a twinx axes of self. This is used for twinx and twiny."""
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.