在地图上绘制countour行Python 2

时间:2017-05-16 01:53:46

标签: python python-2.7 matplotlib contour matplotlib-basemap

我正在尝试在世界地图上绘制等高线,这些线代表特定纬度和经度的磁偏角。

我目前的代码是这样的:

def frange(start, stop, step):
x = start
while x < stop:
        yield x
        x += step
 m = Basemap(width=12000000,height=8000000,
        resolution='l',projection='stere',\
        lat_ts=-10,lat_0=-10,lon_0=-70)
 m.drawcoastlines()
 m.fillcontinents(color='coral',lake_color='aqua')
 m.drawmapboundary(fill_color='aqua')
 delta=0.5
 x=[]
 y=[]
 for i in frange(-80,-29.5,delta):
    x.append(i)
for j in frange(-40,10.5,delta):
    y.append(i)
with open("magdecl.txt", "r") as ins:
z = []
for line in ins:
    z.append(float(line))
 CS = m.contour(x,y,z)
 plt.save("magdecl")
 plt.show()

但是这段代码返回了这样的错误:

IndexError:数组索引太多

我无法在任何地方找到解决方案,轮廓文档也可以提供帮助。 请帮我修改我的代码。

提前致谢!

0 个答案:

没有答案
相关问题