@@ -1135,3 +1135,58 @@ def test_font_wrap():
11351135 plt .text (3 , 4 , t , family = 'monospace' , ha = 'right' , wrap = True )
11361136 plt .text (- 1 , 0 , t , fontsize = 14 , style = 'italic' , ha = 'left' , rotation = - 15 ,
11371137 wrap = True )
1138+
1139+
1140+ def test_ha_for_angle ():
1141+ text_instance = Text ()
1142+ angles = np .arange (0 , 360.1 , 0.1 )
1143+ for angle in angles :
1144+ alignment = text_instance ._ha_for_angle (angle )
1145+ assert alignment in ['center' , 'left' , 'right' ]
1146+
1147+
1148+ def test_va_for_angle ():
1149+ text_instance = Text ()
1150+ angles = np .arange (0 , 360.1 , 0.1 )
1151+ for angle in angles :
1152+ alignment = text_instance ._va_for_angle (angle )
1153+ assert alignment in ['center' , 'top' , 'baseline' ]
1154+
1155+
1156+ @image_comparison (baseline_images = ['xtick_rotation_mode' ],
1157+ remove_text = False , extensions = ['png' ], style = 'mpl20' )
1158+ def test_xtick_rotation_mode ():
1159+ fig , ax = plt .subplots (figsize = (12 , 1 ))
1160+ ax .set_yticks ([])
1161+ ax2 = ax .twiny ()
1162+
1163+ ax .set_xticks (range (37 ), ['foo' ] * 37 , rotation_mode = "xtick" )
1164+ ax2 .set_xticks (range (37 ), ['foo' ] * 37 , rotation_mode = "xtick" )
1165+
1166+ angles = np .linspace (0 , 360 , 37 )
1167+
1168+ for tick , angle in zip (ax .get_xticklabels (), angles ):
1169+ tick .set_rotation (angle )
1170+ for tick , angle in zip (ax2 .get_xticklabels (), angles ):
1171+ tick .set_rotation (angle )
1172+
1173+ plt .subplots_adjust (left = 0.01 , right = 0.99 , top = .6 , bottom = .4 )
1174+
1175+
1176+ @image_comparison (baseline_images = ['ytick_rotation_mode' ],
1177+ remove_text = False , extensions = ['png' ], style = 'mpl20' )
1178+ def test_ytick_rotation_mode ():
1179+ fig , ax = plt .subplots (figsize = (1 , 12 ))
1180+ ax .set_xticks ([])
1181+ ax2 = ax .twinx ()
1182+
1183+ ax .set_yticks (range (37 ), ['foo' ] * 37 , rotation_mode = "ytick" )
1184+ ax2 .set_yticks (range (37 ), ['foo' ] * 37 , rotation_mode = 'ytick' )
1185+
1186+ angles = np .linspace (0 , 360 , 37 )
1187+ for tick , angle in zip (ax .get_yticklabels (), angles ):
1188+ tick .set_rotation (angle )
1189+ for tick , angle in zip (ax2 .get_yticklabels (), angles ):
1190+ tick .set_rotation (angle )
1191+
1192+ plt .subplots_adjust (left = 0.4 , right = 0.6 , top = .99 , bottom = .01 )
0 commit comments