Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6889c6d

Browse files
committed
Merge pull request #9068 from QuLogic/polar-ticks
ENH: Polar tick improvements
1 parent 95691f4 commit 6889c6d

40 files changed

+2107
-1079
lines changed

doc/users/whats_new.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ negative values are simply used as labels, and the real radius is shifted by
6262
the configured minimum. This release also allows negative radii to be used for
6363
grids and ticks, which were previously silently ignored.
6464

65+
Radial ticks have been modified to be parallel to the circular grid line, and
66+
angular ticks have been modified to be parallel to the grid line. It may also
67+
be useful to rotate tick *labels* to match the boundary. Calling
68+
``ax.tick_params(rotation='auto')`` will enable new behavior: radial tick
69+
labels will be parallel to the circular grid line, and angular tick labels will
70+
be perpendicular to the grid line (i.e., parallel to the outer boundary.)
6571

6672

6773
Merge JSAnimation

lib/matplotlib/axis.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)