11from __future__ import (absolute_import , division , print_function ,
22 unicode_literals )
33
4+ import six
5+
46from collections import OrderedDict
57
68import numpy as np
@@ -251,9 +253,9 @@ class ThetaTick(maxis.XTick):
251253 tick location. This results in ticks that are correctly perpendicular to
252254 the arc spine.
253255
254- Labels are also rotated to be parallel to the spine. The label padding is
255- also applied here since it's not possible to use a generic axes transform
256- to produce tick-specific padding.
256+ When 'auto' rotation is enabled, labels are also rotated to be parallel to
257+ the spine. The label padding is also applied here since it's not possible
258+ to use a generic axes transform to produce tick-specific padding.
257259 """
258260 def __init__ (self , axes , * args , ** kwargs ):
259261 self ._text1_translate = mtransforms .ScaledTranslation (
@@ -322,14 +324,15 @@ def update_position(self, loc):
322324 trans = self .tick2line ._marker ._transform
323325 self .tick2line ._marker ._transform = trans
324326
325- if not _is_full_circle_deg (axes .get_thetamin (), axes .get_thetamax ()):
327+ mode , user_angle = self ._labelrotation
328+ if mode == 'default' :
329+ angle = 0
330+ else :
326331 if angle > np .pi / 2 :
327332 angle -= np .pi
328333 elif angle < - np .pi / 2 :
329334 angle += np .pi
330- else :
331- angle = 0
332- angle = np .rad2deg (angle ) + self ._labelrotation
335+ angle = np .rad2deg (angle ) + user_angle
333336 if self .label1On :
334337 self .label1 .set_rotation (angle )
335338 if self .label2On :
@@ -488,8 +491,8 @@ class RadialTick(maxis.YTick):
488491 This subclass of `YTick` provides radial ticks with some small modification
489492 to their re-positioning such that ticks are rotated based on axes limits.
490493 This results in ticks that are correctly perpendicular to the spine. Labels
491- are also rotated to be perpendicular to the spine, but only for wedges, to
492- preserve backwards compatibility .
494+ are also rotated to be perpendicular to the spine, when 'auto' rotation is
495+ enabled .
493496 """
494497 def _get_text1 (self ):
495498 t = super (RadialTick , self )._get_text1 ()
@@ -524,9 +527,14 @@ def update_position(self, loc):
524527 full = _is_full_circle_deg (thetamin , thetamax )
525528
526529 if full :
527- angle = axes .get_rlabel_position ()
530+ angle = axes .get_rlabel_position () * direction + offset - 90
528531 tick_angle = 0
529- text_angle = 0
532+ if angle > 90 :
533+ text_angle = angle - 180
534+ elif angle < - 90 :
535+ text_angle = angle + 180
536+ else :
537+ text_angle = angle
530538 else :
531539 angle = thetamin * direction + offset - 90
532540 if direction > 0 :
@@ -539,7 +547,11 @@ def update_position(self, loc):
539547 text_angle = angle + 180
540548 else :
541549 text_angle = angle
542- text_angle += self ._labelrotation
550+ mode , user_angle = self ._labelrotation
551+ if mode == 'auto' :
552+ text_angle += user_angle
553+ else :
554+ text_angle = user_angle
543555 if self .label1On :
544556 if full :
545557 ha = 'left'
@@ -583,7 +595,11 @@ def update_position(self, loc):
583595 text_angle = angle + 180
584596 else :
585597 text_angle = angle
586- text_angle += self ._labelrotation
598+ mode , user_angle = self ._labelrotation
599+ if mode == 'auto' :
600+ text_angle += user_angle
601+ else :
602+ text_angle = user_angle
587603 if self .label2On :
588604 ha , va = self ._determine_anchor (angle , False )
589605 self .label2 .set_ha (ha )
0 commit comments