顺时针极坐标图的问题

Issues with clockwise polar plot

我有一个代表半径 (r) 的值列表和另一个代表角度 (theta) 的值。我正在尝试制作一个极地图,北为 0 度,东为 90 度,依此类推。

import matplotlib.pyplot as plt 
import numpy as np

theta = [87.23008557164445, 100.26076015446364, 78.71990232378403, 136.34914122677247, 103.6118957767244, 108.8898592700267, 93.2079887669754]

r = [9.672704455052727, 5.747648969819628, 7.8846103848102835, 3.924182947507153, 5.631744483153131, 7.051601437489786, 2.2619972761713196]

colors = ['#c96253', '#e6b065', '#59c752', '#52c7bb', '#5260c7', 'w', 'k']

fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.set_theta_direction(-1)
ax.set_theta_zero_location('N')

for i in range(0, len(r)):
    ax.vlines(theta[i], 0, r[i], colors=colors[i], zorder=3)

列表中的角度与绘制的不符。有人知道怎么解决吗?

您需要以弧度表示 theta 参数。您可以使用 math.radians() 来执行此操作。

import matplotlib.pyplot as plt 
import numpy as np
import math

theta = [87.23008557164445, 100.26076015446364, 78.71990232378403, 136.34914122677247, 103.6118957767244, 108.8898592700267, 93.2079887669754]

r = [9.672704455052727, 5.747648969819628, 7.8846103848102835, 3.924182947507153, 5.631744483153131, 7.051601437489786, 2.2619972761713196]

colors = ['#c96253', '#e6b065', '#59c752', '#52c7bb', '#5260c7', 'w', 'k']

fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.set_theta_direction(-1)
ax.set_theta_zero_location('N')

for i in range(0, len(r)):
    ax.vlines(math.radians(theta[i]), 0, r[i], colors=colors[i], zorder=3)

输出