我尝试了多个动画示例代码,无法使其中任何一个工作.这是我在Matplotlib文档中尝试过的基本内容:
"""
A simple example of an animated plot
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
x = np.arange(0, 2*np.pi, 0.01) # x-array
line, = ax.plot(x, np.sin(x))
def animate(i):
line.set_ydata(np.sin(x+i/10.0)) # update the data
return line,
#Init only required for blitting to give a clean slate.
def init():
line.set_ydata(np.ma.array(x, mask=True))
return line,
ani = animation.FuncAnimation(fig, animate, np.arange(1, 200), init_func=init,
interval=25, blit=True)
plt.show()
Run Code Online (Sandbox Code Playgroud)
当我在IPython Notebook中执行上述操作时,我只看到生成的空白图.我尝试使用多个浏览器(Chrome,FF,IE)从多台服务器(包括Wakari)在多台计算机上运行此程序.
我可以将动画保存到mp4文件就好了,播放时效果很好.
任何帮助表示赞赏!