以下是一个matplolib动画图的代码,这里有如何保存它的方法。
我基本上所做的是将生成的代码复制到像这样的基本HTML脚本中:
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()
我基本上所做的是将生成的代码复制到像这样的基本HTML脚本中:
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<video width="432" height="288" controls autoplay loop> BLABLA </video>
</body>
</html>
图表没有显示,但标题和视频菜单还在。为什么?我该怎么办?
ani.to_html5_video()
如何与BLABLA
相关。可能你只是在复制时犯了一个错误? - ImportanceOfBeingErnest