Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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
Ensure polar ticks are always "right-side up".
  • Loading branch information
QuLogic committed Sep 25, 2017
commit 77e2532dedb305405903441ef7147406c31624e7
61 changes: 52 additions & 9 deletions 61 lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,17 @@ def update_position(self, loc):
self.tick2line._marker._transform = trans

if not _is_full_circle_deg(axes.get_thetamin(), axes.get_thetamax()):
angle = np.rad2deg(angle) + self._labelrotation
if self.label1On:
self.label1.set_rotation(angle)
if self.label2On:
self.label2.set_rotation(angle)
if angle > np.pi / 2:
angle -= np.pi
elif angle < -np.pi / 2:
angle += np.pi
else:
angle = 0
angle = np.rad2deg(angle) + self._labelrotation
if self.label1On:
self.label1.set_rotation(angle)
if self.label2On:
self.label2.set_rotation(angle)

# This extra padding helps preserve the look from previous releases but
# is also needed because labels are anchored to their center.
Expand Down Expand Up @@ -495,6 +501,18 @@ def _get_text2(self):
t.set_rotation_mode('anchor')
return t

def _determine_anchor(self, angle, start):
if start:
if -90 <= angle <= 90:
return 'left', 'center'
else:
return 'right', 'center'
else:
if -90 <= angle <= 90:
return 'right', 'center'
else:
return 'left', 'center'

def update_position(self, loc):
super(RadialTick, self).update_position(loc)
axes = self.axes
Expand All @@ -506,16 +524,31 @@ def update_position(self, loc):
full = _is_full_circle_deg(thetamin, thetamax)

if full:
angle = 0
tick_angle = np.deg2rad(angle)
angle = axes.get_rlabel_position()
tick_angle = 0
text_angle = 0
else:
angle = thetamin * direction + offset - 90
if direction > 0:
tick_angle = np.deg2rad(angle)
else:
tick_angle = np.deg2rad(angle + 180)
if angle > 90:
text_angle = angle - 180
elif angle < -90:
text_angle = angle + 180
else:
text_angle = angle
text_angle += self._labelrotation
if self.label1On:
self.label1.set_rotation(angle + self._labelrotation)
if full:
ha = 'left'
va = 'bottom'
else:
ha, va = self._determine_anchor(angle, True)
self.label1.set_ha(ha)
self.label1.set_va(va)
self.label1.set_rotation(text_angle)
if self.tick1On:
marker = self.tick1line.get_marker()
if marker == mmarkers.TICKLEFT:
Expand Down Expand Up @@ -544,8 +577,18 @@ def update_position(self, loc):
tick_angle = np.deg2rad(angle)
else:
tick_angle = np.deg2rad(angle + 180)
if angle > 90:
text_angle = angle - 180
elif angle < -90:
text_angle = angle + 180
else:
text_angle = angle
text_angle += self._labelrotation
if self.label2On:
self.label2.set_rotation(angle + self._labelrotation)
ha, va = self._determine_anchor(angle, False)
self.label2.set_ha(ha)
self.label2.set_va(va)
self.label2.set_rotation(text_angle)
if self.tick2On:
marker = self.tick2line.get_marker()
if marker == mmarkers.TICKLEFT:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.