Skip to content

Commit 06c5dff

Browse files
kyrachotimhoffm
andauthored
Update lib/matplotlib/text.py
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent ab27d59 commit 06c5dff

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/matplotlib/text.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,17 +1391,18 @@ def set_fontname(self, fontname):
13911391
"""
13921392
self.set_fontfamily(fontname)
13931393

1394-
def _ha_for_angle(self, angle, is_tick_top_enabled):
1394+
def _ha_for_angle(self, angle):
13951395
"""
1396-
Determines horizontal alignment ('ha') based on the angle of rotation
1397-
in degrees. Adjusts for is_tick_top_enabled.
1396+
Determines horizontal alignment ('ha') for rotation_mode "xtick" based on
1397+
the angle of rotation in degrees and the vertical alignment.
13981398
"""
1399+
anchor_at_bottom = self.get_verticalalignment() == 'bottom'
13991400
if (angle < 5 or 85 <= angle < 105 or 355 <= angle < 360 or
14001401
170 <= angle < 190 or 265 <= angle < 275):
14011402
return 'center'
14021403
elif 5 <= angle < 85 or 190 <= angle < 265:
1403-
return 'left' if is_tick_top_enabled else 'right'
1404-
return 'right' if is_tick_top_enabled else 'left'
1404+
return 'left' if anchor_at_bottom else 'right'
1405+
return 'right' if anchor_at_bottom else 'left'
14051406

14061407
def _va_for_angle(self, angle, is_tick_right_enabled):
14071408
"""

0 commit comments

Comments
 (0)