我有两个不同的数据集,在一个公共区域上有不同的(纬度,经度)网格。我正在尝试在公共底图上绘制一个的轮廓和另一个的颤动,然后随着时间的推移对其进行动画处理。我已经关注了这个http://matplotlib.org/basemap/users/examples.html和这个https://github.com/matplotlib/basemap/blob/master/examples/animate.py。
到目前为止,我有:
m = Basemap(llcrnrlon=min(lon),llcrnrlat=min(lat),urcrnrlon=max(lon),urcrnrlat=max(lat),
rsphere=(6378137.00,6356752.3142),resolution='h',projection='merc')
# first dataset
lons, lats = numpy.meshgrid(lon, lat)
X, Y = m(lons, lats)
# second dataset
lons2, lats2 = numpy.meshgrid(lon2, lat2)
xx, yy = m(lons2, lats2)
#colormap
levels = numpy.arange(0,3,0.1)
cmap = plt.cm.get_cmap("gist_rainbow_r")
# create figure.
fig=plt.figure(figsize=(12,8))
ax = fig.add_axes([0.05,0.05,0.8,0.85])
# contourf
i = 0
CS = m.contourf(xx,yy,AUX[i,:,:],levels,cmap=cmap,extend='max')
cbar=plt.colorbar(CS)
# quiver
x = X[0::stp,0::stp] #plot arrows with stp = 2
y = Y[0::stp,0::stp]
uplt = U[i,0::stp,0::stp]
vplt = V[i,0::stp,0::stp]
Q = m.quiver(x,y,uplt,vplt,color='k',scale=15)
qk = ax.quiverkey(Q,0.1,0.1,0.5,'0.5m/s')
# continents
m.drawcoastlines(linewidth=1.25)
m.fillcontinents(color='0.8')
def updatefig(i):
global CS, Q
for c in CS.collections: c.remove()
CS = m.contourf(xx,yy,AUX[i,:,:],levels,cmap=cmap,extend='max')
uplt = U[i,0::stp,0::stp]
vplt = V[i,0::stp,0::stp]
Q.set_UVC(uplt,vplt)
anim = animation.FuncAnimation(fig, updatefig, frames=AUX.shape[0],blit=False)
plt.show()
第一个情节(i = 0)一切正常,但之后我只得到没有叠加任何颤动情节的轮廓动画(但出现颤动键!)两个动画单独工作正常,但不能一起工作。底图上有两个不同的 x,y 是否存在问题?