蟒蛇天文极坐标图

问题描述:

我想绘制使用matplolib,底图和numpy的Python极坐标图中的方位角和高度点。蟒蛇天文极坐标图

winterAzi = 81.67440007, 75.55094006, 67.57616189, 55.73337697 
winterAlt = 11.28088118, 25.0837551, 38.44986883, 50.8769649 


#create instance of basemap, note we want a south polar projection to 90 = E 
myMap = Basemap(projection='spstere',boundinglat=0,lon_0=180,resolution='l',round=True,suppress_ticks=True) 
# set the grid up 
gridX,gridY = 10.0,15.0 
parallelGrid = np.arange(-90.0,90.0,gridX) 
meridianGrid = np.arange(-180.0,180.0,gridY) 

# draw parallel and meridian grid, not labels are off. We have to manually create these. 
myMap.drawparallels(parallelGrid,labels=[False,False,False,False]) 
myMap.drawmeridians(meridianGrid,labels=[False,False,False,False],labelstyle='+/-',fmt='%i') 

# we have to send our values through basemap to convert coordinates, note -winterAlt 
winterX,winterY = myMap(winterAzi,-winterAlt) 

# plot azimuth labels, with a North label. 
ax = plt.gca() 
ax.text(0.5,1.025,'N',transform=ax.transAxes,horizontalalignment='center',verticalalignment='bottom',size=25) 
for para in np.arange(gridY,360,gridY): 
    x= (1.1*0.5*np.sin(np.deg2rad(para)))+0.5 
    y= (1.1*0.5*np.cos(np.deg2rad(para)))+0.5 
    ax.text(x,y,u'%i\N{DEGREE SIGN}'%para,transform=ax.transAxes,horizontalalignment='center',verticalalignment='center') 


# plot the winter values 
myMap.plot(winterX,winterY ,'bo') 


plt.show() 

但是,它并没有在代码的开头绘制数据点! 我如何绘制它们?

你可能希望把这些变量在numpy的数组:

winterAzi = np.array([81.67440007, 75.55094006, 67.57616189, 55.73337697]) 
winterAlt = np.array([11.28088118, 25.0837551, 38.44986883, 50.8769649]) 
+0

等但有一个问题!我可以如下方式使用np.array:对于范围(x到y)中的n: winterAzi = np.array([func(x,y,1)]);; winterAlt = np.array([func(x,y,2)])? – Vick

+0

我不太清楚你想做什么,但你可以尝试列表解析:'winterAzi = np.array([函数(n,1)在范围内(x,y)]);; winterAlt = np.array([func(n,2)for n in range(x,y)])' –