8000 apply_aspect cleanups by anntzer · Pull Request #23577 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

apply_aspect cleanups #23577

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 2 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
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
33 changes: 10 additions & 23 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,23 +2943,17 @@ def _update_title_position(self, renderer):

titles = (self.title, self._left_title, self._right_title)

# Need to check all our twins too, and all the children as well.
axs = self._twinned_axes.get_siblings(self) + self.child_axes
for ax in self.child_axes: # Child positions must be updated first.
locator = ax.get_axes_locator()
ax.apply_aspect(locator(self, renderer) if locator else None)

for title in titles:
x, _ = title.get_position()
# need to start again in case of window resizing
title.set_position((x, 1.0))
# need to check all our twins too...
axs = self._twinned_axes.get_siblings(self)
# and all the children
for ax in self.child_axes:
if ax is not None:
locator = ax.get_axes_locator()
if locator:
pos = locator(self, renderer)
ax.apply_aspect(pos)
else:
ax.apply_aspect()
axs = axs + [ax]
top = -np.Inf
top = -np.inf
for ax in axs:
bb = None
if (ax.xaxis.get_ticks_position() in ['top', 'unknown']
Expand Down Expand Up @@ -3016,11 +3010,7 @@ def draw(self, renderer):

# loop over self and child Axes...
locator = self.get_axes_locator()
if locator:
pos = locator(self, renderer)
self.apply_aspect(pos)
else:
self.apply_aspect()
self.apply_aspect(locator(self, renderer) if locator else None)

artists = self.get_children()
artists.remove(self.patch)
Expand Down Expand Up @@ -4396,11 +4386,8 @@ def get_tightbbox(self, renderer=None, call_axes_locator=True,
return None

locator = self.get_axes_locator()
if locator and call_axes_locator:
pos = locator(self, renderer)
self.apply_aspect(pos)
else:
self.apply_aspect()
self.apply_aspect(
locator(self, renderer) if locator and call_axes_locator else None)

for axis in self._axis_map.values():
if self.axison and axis.get_visible():
Expand Down
13 changes: 3 additions & 10 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,13 @@ def _get_draw_artists(self, renderer):
key=lambda artist: artist.get_zorder())
for ax in self._localaxes:
locator = ax.get_axes_locator()
if locator:
pos = locator(ax, renderer)
ax.apply_aspect(pos)
else:
ax.apply_aspect()
ax.apply_aspect(locator(ax, renderer) if locator else None)

for child in ax.get_children():
if hasattr(child, 'apply_aspect'):
locator = child.get_axes_locator()
if locator:
pos = locator(child, renderer)
child.apply_aspect(pos)
else:
child.apply_aspect()
child.apply_aspect(
locator(child, renderer) if locator else None)
return artists

def autofmt_xdate(
Expand Down
6 changes: 1 addition & 5 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,7 @@ def draw(self, renderer):
# it adjusts the view limits and the size of the bounding box
# of the Axes
locator = self.get_axes_locator()
if locator:
pos = locator(self, renderer)
self.apply_aspect(pos)
else:
self.apply_aspect()
self.apply_aspect(locator(self, renderer) if locator else None)

# add the projection matrix to the renderer
self.M = self.get_proj()
Expand Down
0