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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Cleanup polar tick changes based on review.
  • Loading branch information
QuLogic committed Sep 25, 2017
commit 80a5f10a7d11ee5768af520a62a2e7de6dcc7eb1
29 changes: 13 additions & 16 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,22 +262,22 @@ def __init__(self, axes, *args, **kwargs):
self._text2_translate = mtransforms.ScaledTranslation(
0, 0,
axes.figure.dpi_scale_trans)
maxis.XTick.__init__(self, axes, *args, **kwargs)
super(ThetaTick, self).__init__(axes, *args, **kwargs)

def _get_text1(self):
t = maxis.XTick._get_text1(self)
t = super(ThetaTick, self)._get_text1()
t.set_rotation_mode('anchor')
t.set_transform(t.get_transform() + self._text1_translate)
return t

def _get_text2(self):
t = maxis.XTick._get_text2(self)
t = super(ThetaTick, self)._get_text2()
t.set_rotation_mode('anchor')
t.set_transform(t.get_transform() + self._text2_translate)
return t

def _apply_params(self, **kw):
maxis.XTick._apply_params(self, **kw)
super(ThetaTick, self)._apply_params(**kw)

# Ensure transform is correct; sometimes this gets reset.
trans = self.label1.get_transform()
Expand All @@ -296,7 +296,7 @@ def _update_padding(self, pad, angle):
self._text2_translate.invalidate()

def update_position(self, loc):
maxis.XTick.update_position(self, loc)
super(ThetaTick, self).update_position(loc)
axes = self.axes
angle = (loc * axes.get_theta_direction() +
axes.get_theta_offset() - np.pi / 2)
Expand Down Expand Up @@ -361,19 +361,19 @@ def _wrap_locator_formatter(self):
self.isDefault_majfmt = True

def cla(self):
maxis.XAxis.cla(self)
super(ThetaAxis, self).cla()
self.set_ticks_position('none')
self._wrap_locator_formatter()

def _set_scale(self, value, **kwargs):
maxis.XAxis._set_scale(self, value, **kwargs)
super(ThetaAxis, self)._set_scale(value, **kwargs)
self._wrap_locator_formatter()

def _copy_tick_props(self, src, dest):
'Copy the props from src tick to dest tick'
if src is None or dest is None:
return
maxis.XAxis._copy_tick_props(self, src, dest)
super(ThetaAxis, self)._copy_tick_props(src, dest)

# Ensure that tick transforms are independent so that padding works.
trans = dest._get_text1_transform()[0]
Expand Down Expand Up @@ -463,9 +463,6 @@ def get_matrix(self):
angle = self.axes._realViewLim.xmin
elif self.mode == 'max':
angle = self.axes._realViewLim.xmax
angle %= 2 * np.pi
if angle < 0:
angle += 2 * np.pi

if self.mode in ('rlabel', 'min'):
padx = np.cos(angle - np.pi / 2)
Expand All @@ -489,17 +486,17 @@ class RadialTick(maxis.YTick):
preserve backwards compatibility.
"""
def _get_text1(self):
t = maxis.YTick._get_text1(self)
t = super(RadialTick, self)._get_text1()
t.set_rotation_mode('anchor')
return t

def _get_text2(self):
t = maxis.YTick._get_text2(self)
t = super(RadialTick, self)._get_text2()
t.set_rotation_mode('anchor')
return t

def update_position(self, loc):
maxis.YTick.update_position(self, loc)
super(RadialTick, self).update_position(loc)
axes = self.axes
thetamin = axes.get_thetamin()
thetamax = axes.get_thetamax()
Expand Down Expand Up @@ -592,12 +589,12 @@ def _wrap_locator_formatter(self):
self.isDefault_majloc = True

def cla(self):
maxis.YAxis.cla(self)
super(RadialAxis, self).cla()
self.set_ticks_position('none')
self._wrap_locator_formatter()

def _set_scale(self, value, **kwargs):
maxis.YAxis._set_scale(self, value, **kwargs)
super(RadialAxis, self)._set_scale(value, **kwargs)
self._wrap_locator_formatter()


Expand Down