在 matplotlib 极坐标图上旋转 theta=0
问题描述:
我有以下示例代码:
import numpy as np
import matplotlib.pyplot as plt
import random
data_theta = range(10,171,10)
data_theta_rad = []
for i in data_theta:
data_theta_rad.append(float(i)*np.pi/180.0)
data_r = random.sample(range(70, 90), 17)
print data_theta
print data_r
ax = plt.subplot(111, polar=True)
ax.plot(data_theta_rad, data_r, color='r', linewidth=3)
ax.set_rmax(95)
# ax.set_rmin(70.0)
ax.grid(True)
ax.set_title("Example", va='bottom')
plt.show()
...产生如下内容:
...但我想将 theta=0 设置为West".所以像:
...but I would like to set theta=0 to the 'West'. So something like:
任何想法如何使用 matplotlib 执行此操作(我在 PowerPoint 中制作了下面的图片)?
Any ideas how to do this with matplotlib (I made the pic below in powerpoint) ?
答
简单使用:
ax.set_theta_zero_location("W")
文档中的更多信息 matplotlib.
More info in the documentation of matplotlib.