下面是一个让您开始学习的示例:
import numpy as npfrom matplotlib import pyplot as pltfrom matplotlib import animationX, Y = np.mgrid[:2*np.pi:10j,:2*np.pi:5j]U = np.cos(X)V = np.sin(Y)fig, ax = plt.subplots(1,1)Q = ax.quiver(X, Y, U, V, pivot='mid', color='r', units='inches')ax.set_xlim(-1, 7)ax.set_ylim(-1, 7)def update_quiver(num, Q, X, Y): """updates the horizontal and vertical vector components by a fixed increment on each frame """ U = np.cos(X + num*0.1) V = np.sin(Y + num*0.1) Q.set_UVC(U,V) return Q,# you need to set blit=False, or the first set of arrows never gets# cleared on subsequent framesanim = animation.FuncAnimation(fig, update_quiver, fargs=(Q, X, Y), interval=50, blit=False)fig.tight_layout()plt.show()



