赤平极射太阳图matplotlib polar plot python

2024-10-01 07:25:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试创建一个简单的赤平极射太阳路径图,类似于: http://wiki.naturalfrequency.com/wiki/Sun-Path_Diagram

我可以旋转极坐标图并将比例设置为90。我该如何反转y轴? 当前轴从0>;90转,如何将轴反转到90>;0以表示方位角?在

我试过:

ax.invert_yaxis()
ax.yaxis_inverted()

此外,我该如何创建一个赤平投影而不是等距投影呢?在

我的代码:

^{pr2}$

目前我的代码甚至不能正确地绘制线条,是否需要将角度或度数转换成其他值?在

非常感谢任何帮助。在


Tags: path代码gt路径comhttpwikiax
1条回答
网友
1楼 · 发布于 2024-10-01 07:25:39

我终于有时间玩matplotlib了。经过大量的搜索,正确的方法,正如joekington指出的那样,是将轴子类化。我发现了一种更快速地利用优秀的基础地图模块的方法。在

下面是我为stackoverflow改编的一些代码。太阳的高度和方位角是用太阳系太阳系和一套在大熊猫身上制作的时间序列邮票来计算的。在

import matplotlib.pylab as plt
from mpl_toolkits.basemap import Basemap
import numpy as np

winterAzi = datafomPySolarAzi
winterAlt = datafromPySolarAlt

# 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')

请注意,目前我只绘制点,您必须确保线点在日出/日落时有一个点在alt 0。在

stereographic plot, note I have plotted Winter/Summer Solstice and Autumn Equinox

相关问题 更多 >