@@ -140,7 +140,7 @@ def __init__(self, axes, loc, label,
140
140
labelsize = rcParams ['%s.labelsize' % name ]
141
141
self ._labelsize = labelsize
142
142
143
- self ._labelrotation = labelrotation
143
+ self ._set_labelrotation ( labelrotation )
144
144
145
145
if zorder is None :
146
146
if major :
@@ -167,6 +167,20 @@ def __init__(self, axes, loc, label,
167
167
168
168
self .update_position (loc )
169
169
170
+ def _set_labelrotation (self , labelrotation ):
171
+ if isinstance (labelrotation , six .string_types ):
172
+ mode = labelrotation
173
+ angle = 0
174
+ elif isinstance (labelrotation , (tuple , list )):
175
+ mode , angle = labelrotation
176
+ else :
177
+ mode = 'default'
178
+ angle = labelrotation
179
+ if mode not in ('auto' , 'default' ):
180
+ raise ValueError ("Label rotation mode must be 'default' or "
181
+ "'auto', not '{}'." .format (mode ))
182
+ self ._labelrotation = (mode , angle )
183
+
170
184
def apply_tickdir (self , tickdir ):
171
185
"""
172
186
Calculate self._pad and self._tickmarkers
@@ -331,8 +345,14 @@ def _apply_params(self, **kw):
331
345
self .tick2line .set (** tick_kw )
332
346
for k , v in six .iteritems (tick_kw ):
333
347
setattr (self , '_' + k , v )
348
+
349
+ if 'labelrotation' in kw :
350
+ self ._set_labelrotation (kw .pop ('labelrotation' ))
351
+ self .label1 .set (rotation = self ._labelrotation [1 ])
352
+ self .label2 .set (rotation = self ._labelrotation [1 ])
353
+
334
354
label_list = [k for k in six .iteritems (kw )
335
- if k [0 ] in ['labelsize' , 'labelcolor' , 'labelrotation' ]]
355
+ if k [0 ] in ['labelsize' , 'labelcolor' ]]
336
356
if label_list :
337
357
label_kw = {k [5 :]: v for k , v in label_list }
338
358
self .label1 .set (** label_kw )
0 commit comments