1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
import matplotlib.pyplot as plt import numpy as np from matplotlib import animation
fig,ax = plt.subplots()
x = np.arange(0,2*np.pi,0.1) y= np.sin(x) line, = ax.plot(x,y)
def (i): line.set_ydata(np.sin(x+np.pi*i/30)) return line,
def init(): line.set_ydata(np.sin(x)) return line,
ani = animation.FuncAnimation(fig=fig,func=animate,frames=30,init_func=init,blit=True)
ani.save('/home/xuleilx/workspace/github/github_pages/public/images/animation.gif', writer='imagemagick', fps=30) plt.show()
|
近期评论