Steve Grafton
Steve Grafton

Reputation: 1961

Setting theta-ticks in matplotlib polar plots

My question is related to the following: Scatter polar plot in matlab

I tried looking online but couldn't find any with this axis; instead of the polar plot going 0 to 360 degrees how can I do -180 to 180 instead?

Upvotes: 12

Views: 29131

Answers (1)

Paul H
Paul H

Reputation: 68216

After creating the polar axis, you can simply set the ticks. Note that you have to set the ticks in radians and matplotlib will display in degrees.

Not quite sure how you want to deal the discrepancy at 180 and -180.

import matplotlib.pyplot as plt
fig, ax1 = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
ax1.set_xticks(np.pi/180. * np.linspace(180,  -180, 8, endpoint=False))

polar axis

Upvotes: 11

Related Questions