Below there is the code of a matplolib animation graph and here is how to save it.
from IPython.display import HTML
import matplotlib.pyplot as plt
import matplotlib.animation
import numpy as np
t = np.linspace(0,2*np.pi)
x = np.sin(t)
fig, ax = plt.subplots()
ax.axis([0,2*np.pi,-1,1])
l, = ax.plot([],[])
def animate(i):
l.set_data(t[:i], x[:i]);
ani = matplotlib.animation.FuncAnimation(fig, animate, frames=len(t));
#HTML(ani.to_jshtml())
ani.to_html5_video()
What I basically do is copying the generated code into a basic html script like this one:
Page TitleMy First Heading
BLABLA
Graph is not showing but the heading and the video menu is there. Why? How can I fix it?