Complete the code to import the blitting animation class from matplotlib.
from matplotlib.animation import [1]
The correct class to create animations with blitting in matplotlib is FuncAnimation.
Complete the code to enable blitting in FuncAnimation for better performance.
ani = FuncAnimation(fig, update, frames=100, blit=[1])
Setting blit=True enables blitting, which improves animation performance.
Fix the error in the update function to return the correct object for blitting.
def update(frame): line.set_ydata(data[frame]) return [1]
For blitting to work, the update function must return an iterable of artists, like a list containing the line.
Fill both blanks to create a background for blitting and restore it in the update function.
background = fig.canvas.copy_from_bbox(ax.[1]()) # In update function: fig.canvas.[2](background)
draw() or clear() instead of restore_region().bbox().We copy the background from the axes bounding box using bbox() and restore it with restore_region() for efficient redrawing.
Fill all three blanks to complete the update function using blitting: restore background, redraw line, and update canvas.
def update(frame): fig.canvas.[1](background) line.set_ydata(data[frame]) ax.[2](line) fig.canvas.[3]()
draw() instead of flush_events().The update function restores the background with restore_region, redraws the line with draw_artist, and updates the display with flush_events.