Python Matplotlib极坐标图未在其应打印的位置打印
我尝试在极坐标图中以度表示球坐标方位角和仰角。我有一组值要测试0度、90度、180度和270度,可以清楚地看到,它们没有以它们应该的方位角值绘制 代码: 这是一个明显不精确的结果: 我更改了轴,使其从0度开始,然后顺时针移动,半径表示高程(从圆心处的90º到边界处的0º)。晚了,但: 代码: 结果:Python Matplotlib极坐标图未在其应打印的位置打印,python,matplotlib,Python,Matplotlib,我尝试在极坐标图中以度表示球坐标方位角和仰角。我有一组值要测试0度、90度、180度和270度,可以清楚地看到,它们没有以它们应该的方位角值绘制 代码: 这是一个明显不精确的结果: 我更改了轴,使其从0度开始,然后顺时针移动,半径表示高程(从圆心处的90º到边界处的0º)。晚了,但: 代码: 结果: 这不是度与弧度的对比?我记不清mpl极坐标图,但由于“1”是直角,连续卫星位置之间的角度是相同的(只是不是90度),所以看起来是一样的。当然,除非你不是说角度不精确。@Evert,你是对的θ以弧度
这不是度与弧度的对比?我记不清mpl极坐标图,但由于“1”是直角,连续卫星位置之间的角度是相同的(只是不是90度),所以看起来是一样的。当然,除非你不是说角度不精确。@Evert,你是对的<代码>θ以弧度而不是度为单位。使用
degree*(pi/180.)转换为弧度将得到正确的结果。
还可以使用ax.set_-yticks(范围(0,100,10))
使alt=0
(atr=90
)勾选显示。@Evert这是正确的。我可以接受你的回答,如果你作为一个插入
from matplotlib.pyplot import rc, grid, figure, plot, rcParams, savefig
def generate_satellite_plot(observer_lat, observer_lon):
rc('grid', color='#316931', linewidth=1, linestyle='-')
rc('xtick', labelsize=15)
rc('ytick', labelsize=15)
# force square figure and square axes looks better for polar, IMO
width, height = rcParams['figure.figsize']
size = min(width, height)
# make a square figure
fig = figure(figsize=(size, size))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c')
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
sat_positions = [[1, 30, 0], [2, 60, 90], [3, 30, 180], [4, 50, 270]]
for (PRN, E, Az) in sat_positions:
ax.annotate(str(PRN),
xy=(Az, 90-E), # theta, radius
bbox=dict(boxstyle="round", fc = 'green', alpha = 0.5),
horizontalalignment='center',
verticalalignment='bottom')
ax.set_yticks(range(0, 90, 10)) # Define the yticks
yLabel = ['90', '', '', '60', '', '', '30', '', '', '']
ax.set_yticklabels(yLabel)
grid(True)
savefig('foo.png')
from matplotlib.pyplot import rc, grid, figure, plot, rcParams, savefig
from math import radians
def generate_satellite_plot(observer_lat, observer_lon):
rc('grid', color='#316931', linewidth=1, linestyle='-')
rc('xtick', labelsize=15)
rc('ytick', labelsize=15)
# force square figure and square axes looks better for polar, IMO
width, height = rcParams['figure.figsize']
size = min(width, height)
# make a square figure
fig = figure(figsize=(size, size))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c')
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
sat_positions = [[1, 30, 0], [2, 60, 90], [3, 30, 180], [4, 50, 270]]
for (PRN, E, Az) in sat_positions:
ax.annotate(str(PRN),
xy=(radians(Az), 90-E), # theta, radius
bbox=dict(boxstyle="round", fc = 'green', alpha = 0.5),
horizontalalignment='center',
verticalalignment='center')
ax.set_yticks(range(0, 90+10, 10)) # Define the yticks
yLabel = ['90', '', '', '60', '', '', '30', '', '', '']
ax.set_yticklabels(yLabel)
grid(True)
savefig('foo.png')