8000 Merge pull request #23577 from anntzer/aa · matplotlib/matplotlib@e4bab37 · GitHub
[go: up one dir, main page]

Skip to content

Commit e4bab37

Browse files
authored
Merge pull request #23577 from anntzer/aa
apply_aspect cleanups
2 parents cf38c34 + 5c1f9b0 commit e4bab37

File tree

3 files changed

+14
-38
lines changed

3 files changed

+14
-38
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,23 +2943,17 @@ def _update_title_position(self, renderer):
29432943

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

2946+
# Need to check all our twins too, and all the children as well.
2947+
axs = self._twinned_axes.get_siblings(self) + self.child_axes
2948+
for ax in self.child_axes: # Child positions must be updated first.
2949+
locator = ax.get_axes_locator()
2950+
ax.apply_aspect(locator(self, renderer) if locator else None)
2951+
29462952
for title in titles:
29472953
x, _ = title.get_position()
29482954
# need to start again in case of window resizing
29492955
title.set_position((x, 1.0))
2950-
# need to check all our twins too...
2951-
axs = self._twinned_axes.get_siblings(self)
2952-
# and all the children
2953-
for ax in self.child_axes:
2954-
if ax is not None:
2955-
locator = ax.get_axes_locator()
2956-
if locator:
2957-
pos = locator(self, renderer)
2958-
ax.apply_aspect(pos)
2959-
else:
2960-
ax.apply_aspect()
2961-
axs = axs + [ax]
2962-
top = -np.Inf
2956+
top = -np.inf
29632957
for ax in axs:
29642958
bb = None
29652959
if (ax.xaxis.get_ticks_position() in ['top', 'unknown']
@@ -3016,11 +3010,7 @@ def draw(self, renderer):
30163010

30173011
# loop over self and child Axes...
30183012
locator = self.get_axes_locator()
3019-
if locator:
3020-
pos = locator(self, renderer)
3021-
self.apply_aspect(pos)
3022-
else:
3023-
self.apply_aspect()
3013+
self.apply_aspect(locator(self, renderer) if locator else None)
30243014

30253015
artists = self.get_children()
30263016
artists.remove(self.patch)
@@ -4396,11 +4386,8 @@ def get_tightbbox(self, renderer=None, call_axes_locator=True,
43964386
return None
43974387

43984388
locator = self.get_axes_locator()
4399-
if locator and call_axes_locator:
4400-
pos = locator(self, renderer)
4401-
self.apply_aspect(pos)
4402-
else:
4403-
self.apply_aspect()
4389+
self.apply_aspect(
4390+
locator(self, renderer) if locator and call_axes_locator else None)
44044391

44054392
for axis in self._axis_map.values():
44064393
if self.axison and axis.get_visible():

lib/matplotlib/figure.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,13 @@ def _get_draw_artists(self, renderer):
206206
key=lambda artist: artist.get_zorder())
207207
for ax in self._localaxes:
208208
locator = ax.get_axes_locator()
209-
if locator:
210-
pos = locator(ax, renderer)
211-
ax.apply_aspect(pos)
212-
else:
213-
ax.apply_aspect()
209+
ax.apply_aspect(locator(ax, renderer) if locator else None)
214210

215211
for child in ax.get_children():
216212
if hasattr(child, 'apply_aspect'):
217213
locator = child.get_axes_locator()
218-
if locator:
219-
pos = locator(child, renderer)
220-
child.apply_aspect(pos)
221-
else:
222-
child.apply_aspect()
214+
child.apply_aspect(
215+
locator(child, renderer) if locator else None)
223216
return artists
224217

225218
def autofmt_xdate(

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,7 @@ def draw(self, renderer):
420420
# it adjusts the view limits and the size of the bounding box
421421
# of the Axes
422422
locator = self.get_axes_locator()
423-
if locator:
424-
pos = locator(self, renderer)
425-
self.apply_aspect(pos)
426-
else:
427-
self.apply_aspect()
423+
self.apply_aspect(locator(self, renderer) if locator else None)
428424

429425
# add the projection matrix to the renderer
430426
self.M = self.get_proj()

0 commit comments

Comments
 (0)
0