8000 Backport PR #27578 on branch v3.8.x (Fix polar labels with negative theta limit) by meeseeksmachine · Pull Request #27586 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #27578 on branch v3.8.x (Fix polar labels with negative theta limit) #27586

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
Show file tree
Hide file tree
Changes from all commits
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
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