gpt4 book ai didi

python - 在 matplotlib 极坐标图上旋转 theta=0

转载 作者:IT老高 更新时间:2023-10-28 20:46:37 25 4
gpt4 key购买 nike

我有以下示例代码:

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()

...产生如下内容: enter image description here

...但我想将 theta=0 设置为“西方”。所以像:

enter image description here

任何想法如何使用 matplotlib 做到这一点(我在 powerpoint 中制作了下面的图片)?

最佳答案

简单使用:

ax.set_theta_zero_location("W")

更多信息见 documentation matplotlib.

关于python - 在 matplotlib 极坐标图上旋转 theta=0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26906510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com