@@ -140,7 +140,7 @@ def __init__(self, axes, loc, label,
140140 labelsize = rcParams ['%s.labelsize' % name ]
141141 self ._labelsize = labelsize
142142
143- self ._labelrotation = labelrotation
143+ self ._set_labelrotation ( labelrotation )
144144
145145 if zorder is None :
146146 if major :
@@ -167,6 +167,20 @@ def __init__(self, axes, loc, label,
167167
168168 self .update_position (loc )
169169
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+
170184 def apply_tickdir (self , tickdir ):
171185 """
172186 Calculate self._pad and self._tickmarkers
@@ -331,8 +345,14 @@ def _apply_params(self, **kw):
331345 self .tick2line .set (** tick_kw )
332346 for k , v in six .iteritems (tick_kw ):
333347 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+
334354 label_list = [k for k in six .iteritems (kw )
335- if k [0 ] in ['labelsize' , 'labelcolor' , 'labelrotation' ]]
355+ if k [0 ] in ['labelsize' , 'labelcolor' ]]
336356 if label_list :
337357 label_kw = {k [5 :]: v for k , v in label_list }
338358 self .label1 .set (** label_kw )
0 commit comments