diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 980ef2f51c94..433647516f91 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -1261,6 +1261,14 @@ def __clear(self): # deprecation on cla() subclassing expires. # stash the current visibility state + + # A twinx-copied axis title set to the right will move back the + # left if it is cleared. + set_right_label_again = False + if 'y' in self._axis_map: + set_right_label_again = \ + (self._axis_map['y'].get_label_position() == 'right') + if hasattr(self, 'patch'): patch_visible = self.patch.get_visible() else: @@ -1378,6 +1386,9 @@ def __clear(self): axis._set_lim(0, 1, auto=True) self._update_transScale() + if set_right_label_again: + self._axis_map['y'].set_label_position('right') + self.stale = True def clear(self):