我想要生成随时间变化的温度变化的四面板动画。子图中的四个面板中的每一个都应该是动画地图;每个面板之间的差异是所使用的数据。我已成功地生成用下面的代码使用一组数据(不含副区)动画:插曲动画Matplotlib Subplot动画与底图
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.basemap import Basemap
#dummy temperature data with 10 time-steps
y=np.random.randn(10, 60, 100)
fig = plt.figure()
m = Basemap(projection='kav7',lon_0=0)
lats=np.linspace(90,-90,y.shape[1])
lons=np.linspace(-180,180,y.shape[2])
lons, lats = np.meshgrid(lons,lats)
m.drawparallels(np.arange(-90.,99.,30.), labels=[1,0,0,0])
m.drawmeridians(np.arange(-180.,180.,60.), labels=[0,0,0,1])
m.drawcoastlines(linewidth=0.25)
m.pcolormesh(lons,lats,y[0],cmap=plt.cm.bwr, shading='flat',latlon=True)
def init():
m
def animate(i):
m.pcolormesh(lons,lats,y[i],cmap=plt.cm.bwr, shading='flat',latlon=True)
return m
anim = animation.FuncAnimation(fig, animate, init_func=init, frames=10, interval=100) #interval = number of milliseconds between frames
anim.save('movie.mp4')
我已经看过无数的例子(1,2,3),但仍然不知道如何去做与底图。
如果您链接到您提到的大量示例中的一个,这将是一个更好的问题。 http://matplotlib.org/api/animation_api.html?highlight=funcanimation#matplotlib.animation.FuncAnimation –
感谢您的编辑!并接受答案。欢迎来到SO! –