Skip to content

Polar tick improvements #9068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ negative values are simply used as labels, and the real radius is shifted by
the configured minimum. This release also allows negative radii to be used for
grids and ticks, which were previously silently ignored.

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


Merge JSAnimation
Expand Down
24 changes: 22 additions & 2 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(self, axes, loc, label,
labelsize = rcParams['%s.labelsize' % name]
self._labelsize = labelsize

self._labelrotation = labelrotation
self._set_labelrotation(labelrotation)

if zorder is None:
if major:
Expand All @@ -167,6 +167,20 @@ def __init__(self, axes, loc, label,

self.update_position(loc)

def _set_labelrotation(self, labelrotation):
if isinstance(labelrotation, six.string_types):
mode = labelrotation
angle = 0
elif isinstance(labelrotation, (tuple, list)):
mode, angle = labelrotation
else:
mode = 'default'
angle = labelrotation
if mode not in ('auto', 'default'):
raise ValueError("Label rotation mode must be 'default' or "
"'auto', not '{}'.".format(mode))
self._labelrotation = (mode, angle)

def apply_tickdir(self, tickdir):
"""
Calculate self._pad and self._tickmarkers
Expand Down Expand Up @@ -331,8 +345,14 @@ def _apply_params(self, **kw):
self.tick2line.set(**tick_kw)
for k, v in six.iteritems(tick_kw):
setattr(self, '_' + k, v)

if 'labelrotation' in kw:
self._set_labelrotation(kw.pop('labelrotation'))
self.label1.set(rotation=self._labelrotation[1])
self.label2.set(rotation=self._labelrotation[1])

label_list = [k for k in six.iteritems(kw)
if k[0] in ['labelsize', 'labelcolor', 'labelrotation']]
if k[0] in ['labelsize', 'labelcolor']]
if label_list:
label_kw = {k[5:]: v for k, v in label_list}
self.label1.set(**label_kw)
Expand Down
Loading