其他分享
首页 > 其他分享> > matplotplib动态曲线

matplotplib动态曲线

作者:互联网

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation
from numpy.core.fromnumeric import repeat

fig,ax = plt.subplots()
xdata,ydata = [],[]

ln, = ax.plot([],[],animated=True)
ax.set_xlim(0,2*np.pi)
ax.set_ylim(-1,1)

xdata = np.linspace(0,2*np.pi,100)
ydata = np.sin(xdata)


def updata(frame):
  ln.set_data(xdata[:frame],ydata[:frame])
  return ln,

lin_ = animation.FuncAnimation(fig,updata,
                                frames = xdata.size,
                                interval=30,blit=True,
                                repeat=False)

plt.show()

 

标签:set,matplotplib,frame,曲线,xdata,import,np,ax,动态
来源: https://www.cnblogs.com/yinsedeyinse/p/15404451.html