import matplotlib.pylab as plt import numpy as np import matplotlib.animation as animation fig = plt.figure() ax = fig.add_subplot(111) n= 10 x= np.random.rand(n) y= np.random.rand(n) z= np.random.rand(n) ###^代表三角星,*代表五角星 +代表十字 ,b,g,b代表颜色 circles,pentagon,dots = ax.plot(x,'bo',y,'g+',z,'b.') ax.set_ylim(0,1) plt.axis('off') #更新屏幕的内容 def update(data): circles.set_ydata(data[0]) pentagon.set_ydata(data[1]) return circles,pentagon #使用numpy生成随机数 def generated(): while True: yield np.random.rand(2,n) anim = animation.FuncAnimation(fig,update,generated,interval=150) plt.show()
matplotlib制作动画
最新推荐文章于 2023-06-15 23:00:43 发布