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 eca6b49

Browse filesBrowse files
committed
Fix tick auto-orientation on clockwise polar plots.
They ended up upside down because of the negative angle after accounting for axis direction. The normalization should work for clockwise plots and those that start with any arbitrary start offset.
1 parent 332b986 commit eca6b49
Copy full SHA for eca6b49

File tree

Expand file treeCollapse file tree

1 file changed

+15
-13
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-13
lines changed

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+15-13Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,9 @@ def _update_padding(self, pad, angle):
300300
def update_position(self, loc):
301301
super(ThetaTick, self).update_position(loc)
302302
axes = self.axes
303-
angle = (loc * axes.get_theta_direction() +
304-
axes.get_theta_offset() - np.pi / 2)
303+
angle = loc * axes.get_theta_direction() + axes.get_theta_offset()
304+
text_angle = np.rad2deg(angle) % 360 - 90
305+
angle -= np.pi / 2
305306

306307
if self.tick1On:
307308
marker = self.tick1line.get_marker()
@@ -326,17 +327,17 @@ def update_position(self, loc):
326327

327328
mode, user_angle = self._labelrotation
328329
if mode == 'default':
329-
angle = 0
330+
text_angle = user_angle
330331
else:
331-
if angle > np.pi / 2:
332-
angle -= np.pi
333-
elif angle < -np.pi / 2:
334-
angle += np.pi
335-
angle = np.rad2deg(angle) + user_angle
332+
if text_angle > 90:
333+
text_angle -= 180
334+
elif text_angle < -90:
335+
text_angle += 180
336+
text_angle += user_angle
336337
if self.label1On:
337-
self.label1.set_rotation(angle)
338+
self.label1.set_rotation(text_angle)
338339
if self.label2On:
339-
self.label2.set_rotation(angle)
340+
self.label2.set_rotation(text_angle)
340341

341342
# This extra padding helps preserve the look from previous releases but
342343
# is also needed because labels are anchored to their center.
@@ -527,7 +528,8 @@ def update_position(self, loc):
527528
full = _is_full_circle_deg(thetamin, thetamax)
528529

529530
if full:
530-
angle = axes.get_rlabel_position() * direction + offset - 90
531+
angle = (axes.get_rlabel_position() * direction +
532+
offset) % 360 - 90
531533
tick_angle = 0
532534
if angle > 90:
533535
text_angle = angle - 180
@@ -536,7 +538,7 @@ def update_position(self, loc):
536538
else:
537539
text_angle = angle
538540
else:
539-
angle = thetamin * direction + offset - 90
541+
angle = (thetamin * direction + offset) % 360 - 90
540542
if direction > 0:
541543
tick_angle = np.deg2rad(angle)
542544
else:
@@ -584,7 +586,7 @@ def update_position(self, loc):
584586
self.label2On = False
585587
self.tick2On = False
586588
else:
587-
angle = thetamax * direction + offset - 90
589+
angle = (thetamax * direction + offset) % 360 - 90
588590
if direction > 0:
589591
tick_angle = np.deg2rad(angle)
590592
else:

0 commit comments

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