Skip to content

Commit a242de0

Browse files
committed
Call apply_aspect just once per axes in _update_title_position.
... not once per title.
1 parent bf9a451 commit a242de0

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lib/matplotlib/axes/_base.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -2943,23 +2943,21 @@ 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+
if locator:
2951+
pos = locator(self, renderer)
2952+
ax.apply_aspect(pos)
2953+
else:
2954+
ax.apply_aspect()
2955+
29462956
for title in titles:
29472957
x, _ = title.get_position()
29482958
# need to start again in case of window resizing
29492959
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
2960+
top = -np.inf
29632961
for ax in axs:
29642962
bb = None
29652963
if (ax.xaxis.get_ticks_position() in ['top', 'unknown']

0 commit comments

Comments
 (0)