@@ -149,7 +149,7 @@ def __init__(
149149 # grid(color=(1, 1, 1, 0.5), alpha=rcParams['grid.alpha'])
150150 # so the that the rcParams default would override color alpha.
151151 grid_alpha = mpl .rcParams ["grid.alpha" ]
152- grid_kw = {k [5 :]: v for k , v in kwargs .items ()}
152+ grid_kw = {k [5 :]: v for k , v in kwargs .items () if k != "rotation_mode" }
153153
154154 self .tick1line = mlines .Line2D (
155155 [], [],
@@ -346,6 +346,11 @@ def _apply_params(self, **kwargs):
346346 if k in _gridline_param_names }
347347 self .gridline .set (** grid_kw )
348348
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+
349354 def update_position (self , loc ):
350355 """Set the location of tick in data coords with scalar *loc*."""
351356 raise NotImplementedError ('Derived must override' )
@@ -1049,12 +1054,11 @@ def get_tick_params(self, which='major'):
10491054 _api .check_in_list (['major' , 'minor' ], which = which )
10501055 if which == 'major' :
10511056 return self ._translate_tick_params (
1052- self ._major_tick_kw , reverse = True
1053- )
1057+ self ._major_tick_kw , reverse = True )
10541058 return self ._translate_tick_params (self ._minor_tick_kw , reverse = True )
10551059
1056- @staticmethod
1057- def _translate_tick_params (kw , reverse = False ):
1060+ @classmethod
1061+ def _translate_tick_params (cls , kw , reverse = False ):
10581062 """
10591063 Translate the kwargs supported by `.Axis.set_tick_params` to kwargs
10601064 supported by `.Tick._apply_params`.
@@ -1078,7 +1082,7 @@ def _translate_tick_params(kw, reverse=False):
10781082 'tick1On' , 'tick2On' , 'label1On' , 'label2On' ,
10791083 'length' , 'direction' , 'left' , 'bottom' , 'right' , 'top' ,
10801084 'labelleft' , 'labelbottom' , 'labelright' , 'labeltop' ,
1081- 'labelrotation' ,
1085+ 'labelrotation' , 'rotation_mode' ,
10821086 * _gridline_param_names ]
10831087
10841088 keymap = {
@@ -1096,10 +1100,20 @@ def _translate_tick_params(kw, reverse=False):
10961100 'labeltop' : 'label2On' ,
10971101 }
10981102 if reverse :
1099- kwtrans = {
1100- oldkey : kw_ .pop (newkey )
1101- for oldkey , newkey in keymap .items () if newkey in kw_
1102- }
1103+ is_x_axis = cls .axis_name == 'x'
1104+ kwtrans = {}
1105+ for oldkey , newkey in keymap .items ():
1106+ if newkey in kw_ :
1107+ if is_x_axis and newkey == 'label1On' :
1108+ kwtrans ['labelbottom' ] = kw_ .pop (newkey )
1109+ elif is_x_axis and newkey == 'tick1On' :
1110+ kwtrans ['bottom' ] = kw_ .pop (newkey )
1111+ elif is_x_axis and newkey == 'label2On' :
1112+ kwtrans ['labeltop' ] = kw_ .pop (newkey )
1113+ elif is_x_axis and newkey == 'tick2On' :
1114+ kwtrans ['top' ] = kw_ .pop (newkey )
1115+ else :
1116+ kwtrans [oldkey ] = kw_ .pop (newkey )
11031117 else :
11041118 kwtrans = {
11051119 newkey : kw_ .pop (oldkey )
0 commit comments