Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Matplotlib) expand_more
Matplotlib / Output & Interaction

Animation FuncAnimation

Learn Animation FuncAnimation in Matplotlib with a dedicated explanation, a topic-specific example, edge guidance, and a mastery check.

12 min read • Advanced
matplotlib-061.py
python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation
fig,ax=plt.subplots(); line,=ax.plot([],[]); ax.set(xlim=(0,10),ylim=(-1,1))
def update(frame):
    x=np.linspace(0,frame/10,100); line.set_data(x,np.sin(x)); return line,
ani=FuncAnimation(fig,update,frames=100,interval=30,blit=True)
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content