繁体   English   中英

立体太阳图matplotlib极坐标图python

[英]Stereographic Sun Diagram matplotlib polar plot python

我正在尝试创建类似于以下内容的简单立体太阳路径图: http : //wiki.naturalfrequency.com/wiki/Sun-Path_Diagram

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

我试过了:

ax.invert_yaxis()
ax.yaxis_inverted()

此外,我将如何创建立体投影而不是等距投影?

我的代码:

import matplotlib.pylab as plt
testFig = plt.figure(1, figsize=(8,8))
rect = [0.1,0.1,0.8,0.8]
testAx = testFig.add_axes(rect,polar=True)
testAx.invert_yaxis()
testAx.set_theta_zero_location('N')
testAx.set_theta_direction(-1)

Azi = [90,180,270]
Alt= [0,42,0]
testAx.plot(Azi,Alt)
plt.show()

目前,我的代码似乎甚至无法正确绘制线条,我是否需要将角度或角度转换为其他形状?

任何帮助是极大的赞赏。

我终于有时间玩matplotlib。 经过大量搜索之后,乔·肯顿(Joe Kington)指出,正确的方法是将轴子类化。 我发现了使用出色的底图模块的更快方法。

以下是一些我已适应stackoverflow的代码。 太阳高度和方位角是使用Pysolar计算的,并带有在熊猫中创建的一组时间序列戳记。

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

请注意,当前我仅是绘制点,您必须确保在日出/日落时线点的高度为0。

立体图,请注意,我已绘制了冬至夏至秋分

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM