Skip to content

Commit c57d8e1

Browse files
committed
Fix polar labels with negative theta limit
1 parent e5a85f9 commit c57d8e1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: lib/matplotlib/projections/polar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def set_axis(self, axis):
298298
def __call__(self):
299299
lim = self.axis.get_view_interval()
300300
if _is_full_circle_deg(lim[0], lim[1]):
301-
return np.arange(8) * 2 * np.pi / 8
301+
return np.deg2rad(min(lim)) + np.arange(8) * 2 * np.pi / 8
302302
else:
303303
return np.deg2rad(self.base())
304304

Diff for: lib/matplotlib/tests/test_polar.py

+8
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,11 @@ def test_polar_log():
446446

447447
n = 100
448448
ax.plot(np.linspace(0, 2 * np.pi, n), np.logspace(0, 2, n))
449+
450+
451+
def test_polar_neg_theta_lims():
452+
fig = plt.figure()
453+
ax = fig.add_subplot(projection='polar')
454+
ax.set_thetalim(-np.pi, np.pi)
455+
labels = [l.get_text() for l in ax.xaxis.get_ticklabels()]
456+
assert labels == ['-180°', '-135°', '-90°', '-45°', '0°', '45°', '90°', '135°']

0 commit comments

Comments
 (0)