8000 A twinx-copied axis with a right-aligned title will remain right · matplotlib/matplotlib@877b630 · GitHub
[go: up one dir, main page]

Skip to content

Commit 877b630

Browse files
committed
A twinx-copied axis with a right-aligned title will remain right
1 parent a833d99 commit 877b630

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,14 @@ def __clear(self):
12611261
# deprecation on cla() subclassing expires.
12621262

12631263
# stash the current visibility state
1264+
1265+
# A twinx-copied axis title set to the right will move back the
1266+
# left if it is cleared.
1267+
set_right_label_again = False
1268+
if 'y' in self._axis_map:
1269+
set_right_label_again = \
1270+
(self._axis_map['y'].get_label_position() == 'right')
1271+
12641272
if hasattr(self, 'patch'):
12651273
patch_visible = self.patch.get_visible()
12661274
else:
@@ -1378,6 +1386,9 @@ def __clear(self):
13781386
axis._set_lim(0, 1, auto=True)
13791387
self._update_transScale()
13801388

1389+
if set_right_label_again:
1390+
self._axis_map['y'].set_label_position('right')
1391+
13811392
self.stale = True
13821393

13831394
def clear(self):

0 commit comments

Comments
 (0)
0