import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
from matplotlib.animation import PillowWriter
fig, axis = plt.subplots()
X = np.linspace(1, 10, 100)
Y = np.sin(X)
X_len = len(X)
def update(frame):
if frame == 0:
axis.clear()
axis.plot(X[:frame], Y[:frame])
axis.set_xlim(0, 10)
axis.set_ylim(-3, 3)
animation = animation.FuncAnimation(fig = fig, func = update, frames = X_len, interval = 1)
animation.save("my_animation.gif", writer = PillowWriter(fps = 60))
plt.show()
This is my code. Can someone explain to me why the saved animation appears to be slower than the animation that shows up in the window produced by plt.show()?