0
所以我想知道什麼是最好的技術迭代數組,然後在matplotlib函數,drawgreatcircles中使用這些值。Numpy數組迭代和Matplotlib函數調用
說我有值的四列的列表:
-170.13 -16.57 161.63 -77.37
-170.13 -16.57 163.01 -77.575
127.03 -1.047 162.65 -75.075
127.03 -1.047 160.56 -77.28
127.03 -1.047 161.63 -77.37
127.03 -1.047 163.01 -77.575
我想每一行迭代,並在matplotlib.basemap功能使用這些元素,drawgreatcircle。我知道我下面的代碼寫得很差,我爲每個x,每個y等迭代...換句話說,我繪製的方式比我需要的更多大圓,因爲每個x都與每個y迭代, 等等。
我想要做的是遍歷每一行,其中每行讀入drwagreatcircle函數並繪製該行?我忽略了繪製該圖的matplotlib底圖腳本的一部分:下面的內容只是讀取進入drawgreatcircle的值。
rays = open('ray_temp', 'r')
paths = rays.readlines()
rays.close()
evlo = []
evla = []
stlo = []
stla = []
for i in paths:
gcarc = i.split()
evlo.append(float(gcarc[0]))
evla.append(float(gcarc[1]))
stlo.append(float(gcarc[2]))
stla.append(float(gcarc[3]))
EVLO = np.array(evlo)
EVLA = np.array(evla)
STLO = np.array(stlo)
STLA = np.array(stla)
for x in np.nditer(EVLO):
for y in np.nditer(EVLA):
for z in np.nditer(STLO):
for w in np.nditer(STLA):
map.drawgreatcircle(x,y,z,w)
plt.show()
ü[R做某事錯numpy的創建,使你不HV使用for循環,即使你試圖做到這一點,矢量化函數 – lingxiao