在地图上绘制countour线Python 2

在地图上绘制countour线Python 2,python,python-2.7,matplotlib,contour,matplotlib-basemap,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

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

我目前的代码是:

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()
def法兰(启动、停止、步骤):
x=开始
当x
但此代码返回这样的错误:

索引器:数组的索引太多

我在任何地方都找不到解决方案,轮廓文档也帮不上忙。 请帮我修改代码


提前谢谢

有什么理由不使用geopandas吗?我从未使用过geopandas。我只是习惯了用这种方式绘制地图。我认为这里不需要像geopandas这样的额外软件包。但问题是由如何读取和/或使用数据引起的<代码>轮廓
需要一个2D数组作为Z参数的输入。这里的情况似乎不是这样。由于我们完全没有关于您的数据的信息,我们无法进一步帮助您。看见