我尝试在极坐标图中表示球面坐标方位角和仰角度。我有一组值可以测试0度,90度,180度和270度,可以清楚地看到它们没有绘制在它们应该的方位角值上。
代码:
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')
这是结果,显然不精确:
我更改了轴,使它们从0度开始然后顺时针方向移动,半径代表高度(从圆心90º到边界0º)。
答案 0 :(得分:2)
迟到了,但是:
代码:
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')
结果:
答案 1 :(得分:-1)
import numpy as np
import matplotlib.pyplot as plt
def generate_satellite_plot(Az,El):
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)
ax.plot(np.deg2rad(Az),90-El,'*')
ax.set_yticks(range(0, 90+10, 30)) # Define the yticks
yLabel = ['90', '60','30','0']
ax.set_yticklabels(yLabel)
ax.set_xticks(np.arange(0, np.pi*2, np.pi/2)) # Define the xticks
xLabel = ['N' , 'E','S','W']
ax.set_xticklabels(xLabel)
plt.show()
Az=[90, 180, 270]
El=[20, 30, 10]
Az= np.array(Az)
El= np.array(El)
generate_satellite_plot(Az,El)