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()