[英]Rotate theta=0 on matplotlib polar plot
I have the following example code:我有以下示例代码:
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()
...which produces something like this: ...产生这样的东西:
...but I would like to set theta=0 to the 'West'. ...但我想将 theta=0 设置为“West”。 So something like:所以像:
Any ideas how to do this with matplotlib (I made the pic below in powerpoint) ?任何想法如何使用 matplotlib 执行此操作(我在 powerpoint 中制作了下面的图片)?
Simply use:只需使用:
ax.set_theta_zero_location("W")
More info in the documentation of matplotlib. matplotlib 文档中的更多信息。
A more flexible way:更灵活的方式:
ax.set_theta_offset(pi)
You can rotate the axis arbitrarily, just replace pi
with the angle you want.可以任意旋转轴,用你想要的角度替换pi
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.