簡體   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