0
我想用Cartopy創建一個簡單的動畫。基本上只需在地圖上畫幾行即可。到目前爲止,我正在嘗試以下內容:如何做Cartopy簡單動畫
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import matplotlib.animation as animation
import numpy as np
ax = plt.axes(projection=ccrs.Robinson())
ax.set_global()
ax.coastlines()
lons = 10 * np.arange(1, 10)
lats = 10 * np.arange(1, 10)
def animate(i):
plt.plot([lons[i-1], lons[i]], [lats[i-1], lats[i]], color='blue', transform=ccrs.PlateCarree())
return plt
anim = animation.FuncAnimation(plt.gcf(), animate, frames=np.arange(1, 8), init_func=None, interval=2000, blit=True)
plt.show()
有沒有人知道爲什麼這不起作用?