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

Commit 4d044e0

Browse filesBrowse files
authored
Merge pull request #13294 from anntzer/polar
Simplify some calculations in polar.py.
2 parents a2a57a6 + c91ca7b commit 4d044e0
Copy full SHA for 4d044e0

File tree

Expand file treeCollapse file tree

1 file changed

+8
-32
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-32
lines changed

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+8-32Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -598,24 +598,13 @@ def update_position(self, loc):
598598
angle = (axes.get_rlabel_position() * direction +
599599
offset) % 360 - 90
600600
tick_angle = 0
601-
if angle > 90:
602-
text_angle = angle - 180
603-
elif angle < -90:
604-
text_angle = angle + 180
605-
else:
606-
text_angle = angle
607601
else:
608602
angle = (thetamin * direction + offset) % 360 - 90
609603
if direction > 0:
610604
tick_angle = np.deg2rad(angle)
611605
else:
612606
tick_angle = np.deg2rad(angle + 180)
613-
if angle > 90:
614-
text_angle = angle - 180
615-
elif angle < -90:
616-
text_angle = angle + 180
617-
else:
618-
text_angle = angle
607+
text_angle = (angle + 90) % 180 - 90 # between -90 and +90.
619608
mode, user_angle = self._labelrotation
620609
if mode == 'auto':
621610
text_angle += user_angle
@@ -646,18 +635,12 @@ def update_position(self, loc):
646635
if full:
647636
self.label2.set_visible(False)
648637
self.tick2line.set_visible(False)
638+
angle = (thetamax * direction + offset) % 360 - 90
639+
if direction > 0:
640+
tick_angle = np.deg2rad(angle)
649641
else:
650-
angle = (thetamax * direction + offset) % 360 - 90
651-
if direction > 0:
652-
tick_angle = np.deg2rad(angle)
653-
else:
654-
tick_angle = np.deg2rad(angle + 180)
655-
if angle > 90:
656-
text_angle = angle - 180
657-
elif angle < -90:
658-
text_angle = angle + 180
659-
else:
660-
text_angle = angle
642+
tick_angle = np.deg2rad(angle + 180)
643+
text_angle = (angle + 90) % 180 - 90 # between -90 and +90.
661644
mode, user_angle = self._labelrotation
662645
if mode == 'auto':
663646
text_angle += user_angle
@@ -792,15 +775,8 @@ def get_points(self):
792775

793776
# Ensure equal aspect ratio.
794777
w, h = self._points[1] - self._points[0]
795-
if h < w:
796-
deltah = (w - h) / 2.0
797-
deltaw = 0.0
798-
elif w < h:
799-
deltah = 0.0
800-
deltaw = (h - w) / 2.0
801-
else:
802-
deltah = 0.0
803-
deltaw = 0.0
778+
deltah = max(w - h, 0) / 2
779+
deltaw = max(h - w, 0) / 2
804780
self._points += np.array([[-deltaw, -deltah], [deltaw, deltah]])
805781

806782
self._invalid = 0

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.