Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2a80a7

Browse files
committed
Fix shifted ylabels (#1571)
Force 'anchor' rotation mode when setting the label position, and use the appropriate alignment for the Y-label position.
1 parent a0d82ac commit b2a80a7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/axis.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,10 +1887,12 @@ def set_label_position(self, position):
18871887
ACCEPTS: [ 'left' | 'right' ]
18881888
"""
18891889
assert position == 'left' or position == 'right'
1890-
if position == 'right':
1891-
self.label.set_horizontalalignment('left')
1890+
self.label.set_rotation_mode('anchor')
1891+
self.label.set_horizontalalignment('center')
1892+
if position == 'left':
1893+
self.label.set_verticalalignment('bottom')
18921894
else:
1893-
self.label.set_horizontalalignment('right')
1895+
self.label.set_verticalalignment('top')
18941896
self.label_position = position
18951897

18961898
def _update_label_position(self, bboxes, bboxes2):

0 commit comments

Comments
 (0)