@@ -346,6 +346,11 @@ def _apply_params(self, **kwargs):
346
346
if k in _gridline_param_names }
347
347
self .gridline .set (** grid_kw )
348
348
349
+ if 'rotation_mode' in kwargs :
350
+ rotation_mode = kwargs .pop ('rotation_mode' )
351
+ self .label1 .set_rotation_mode (rotation_mode )
352
+ self .label2 .set_rotation_mode (rotation_mode )
353
+
349
354
def update_position (self , loc ):
350
355
"""Set the location of tick in data coords with scalar *loc*."""
351
356
raise NotImplementedError ('Derived must override' )
@@ -1041,14 +1046,15 @@ def get_tick_params(self, which='major'):
1041
1046
1042
1047
"""
1043
1048
_api .check_in_list (['major' , 'minor' ], which = which )
1049
+ is_x_axis = True if isinstance (self , XAxis ) else False
1044
1050
if which == 'major' :
1045
1051
return self ._translate_tick_params (
1046
- self ._major_tick_kw , reverse = True
1047
- )
1048
- return self ._translate_tick_params ( self . _minor_tick_kw , reverse = True )
1052
+ self ._major_tick_kw , reverse = True , is_x_axis = is_x_axis )
1053
+ return self . _translate_tick_params (
1054
+ self ._minor_tick_kw , reverse = True , is_x_axis = is_x_axis )
1049
1055
1050
1056
@staticmethod
1051
- def _translate_tick_params (kw , reverse = False ):
1057
+ def _translate_tick_params (kw , reverse = False , is_x_axis = None ):
1052
1058
"""
1053
1059
Translate the kwargs supported by `.Axis.set_tick_params` to kwargs
1054
1060
supported by `.Tick._apply_params`.
@@ -1072,7 +1078,7 @@ def _translate_tick_params(kw, reverse=False):
1072
1078
'tick1On' , 'tick2On' , 'label1On' , 'label2On' ,
1073
1079
'length' , 'direction' , 'left' , 'bottom' , 'right' , 'top' ,
1074
1080
'labelleft' , 'labelbottom' , 'labelright' , 'labeltop' ,
1075
- 'labelrotation' ,
1081
+ 'labelrotation' , 'rotation_mode' ,
1076
1082
* _gridline_param_names ]
1077
1083
1078
1084
keymap = {
@@ -1090,10 +1096,19 @@ def _translate_tick_params(kw, reverse=False):
1090
1096
'labeltop' : 'label2On' ,
1091
1097
}
1092
1098
if reverse :
1093
- kwtrans = {
1094
- oldkey : kw_ .pop (newkey )
1095
- for oldkey , newkey in keymap .items () if newkey in kw_
1096
- }
1099
+ kwtrans = {}
1100
+ for oldkey , newkey in keymap .items ():
1101
+ if newkey in kw_ :
1102
+ if is_x_axis and newkey == 'label1On' :
1103
+ kwtrans ['labelbottom' ] = kw_ .pop (newkey )
1104
+ elif is_x_axis and newkey == 'tick1On' :
1105
+ kwtrans ['bottom' ] = kw_ .pop (newkey )
1106
+ elif is_x_axis and newkey == 'label2On' :
1107
+ kwtrans ['labeltop' ] = kw_ .pop (newkey )
1108
+ elif is_x_axis and newkey == 'tick2On' :
1109
+ kwtrans ['top' ] = kw_ .pop (newkey )
1110
+ else :
1111
+ kwtrans [oldkey ] = kw_ .pop (newkey )
1097
1112
else :
1098
1113
kwtrans = {
1099
1114
newkey : kw_ .pop (oldkey )
@@ -2095,6 +2110,8 @@ def set_ticklabels(self, labels, *, minor=False, fontdict=None, **kwargs):
2095
2110
for pos , (loc , tick ) in enumerate (zip (locs , ticks )):
2096
2111
tick .update_position (loc )
2097
2112
tick_label = formatter (loc , pos )
2113
+ tick .label1 .axes = self .axes
2114
+ tick .label2 .axes = self .axes
2098
2115
# deal with label1
2099
2116
tick .label1 .set_text (tick_label )
2100
2117
tick .label1 ._internal_update (kwargs )
0 commit comments