简体   繁体   中英

Reorient Matplotlib polar plot

I would like to produce a polar scatterplot in matplotlib. The plot I have from using ax1 = plt.subplot(111, polar=True) looks fine, but I need to deviate from the usual polar graph orientation.

  1. I need 0 degrees to point straight up (rotation).
  2. I need 90 degrees to point right (mirror image).

(How) Can I do this?

You need ax.set_theta_zero_location and ax.set_theta_direction . For details, see the doc

import matplotlib.pyplot as plt
import numpy as np


r = range(360)
angles = [i * np.pi / 180 for i in r]

f = plt.figure()
ax = plt.subplot(polar=True)
plt.polar(angles, r)

ax.set_xticks(angles[::10])
ax.set_theta_zero_location("N")
ax.set_theta_direction(-1)

plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM