Вы можете сохранить фигуру непосредственно в функции обновления:
fig, ax = plt.subplots()
l, = ax.plot(range(10),[0]*10,'r-')
ax.set_ylim(0,1)
def animate(i):
y = np.random.random(size=(10,))
l.set_ydata(y)
fig.savefig(f'test_{i}.png')
return l,
ani = animation.FuncAnimation(fig, animate, frames=10)