Skip to content

Commit

Permalink
Merge pull request #27586 from meeseeksmachine/auto-backport-of-pr-27…
Browse files Browse the repository at this point in the history
…578-on-v3.8.x

Backport PR #27578 on branch v3.8.x (Fix polar labels with negative theta limit)
  • Loading branch information
timhoffm committed Dec 30, 2023
2 parents 1566e5e + 2e01b0c commit 6eca804
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def set_axis(self, axis):
def __call__(self):
lim = self.axis.get_view_interval()
if _is_full_circle_deg(lim[0], lim[1]):
return np.arange(8) * 2 * np.pi / 8
return np.deg2rad(min(lim)) + np.arange(8) * 2 * np.pi / 8
else:
return np.deg2rad(self.base())

Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,11 @@ def test_polar_log():

n = 100
ax.plot(np.linspace(0, 2 * np.pi, n), np.logspace(0, 2, n))


def test_polar_neg_theta_lims():
fig = plt.figure()
ax = fig.add_subplot(projection='polar')
ax.set_thetalim(-np.pi, np.pi)
labels = [l.get_text() for l in ax.xaxis.get_ticklabels()]
assert labels == ['-180°', '-135°', '-90°', '-45°', '0°', '45°', '90°', '135°']

0 comments on commit 6eca804

Please sign in to comment.