【发布时间】:2014-10-09 14:54:01
【问题描述】:
我尝试了多个动画示例代码,但其中任何一个都无法正常工作。这是我从 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()
当我在 IPython Notebook 中执行上述操作时,我只看到生成了一个空白图。我已经尝试使用多个浏览器(Chrome、FF、IE)从多台服务器(包括 Wakari)、多台机器上运行它。
我可以将动画保存为 mp4 文件,播放时看起来不错。
感谢任何帮助!
【问题讨论】:
-
在不使用内嵌图形的情况下运行它。
标签: matplotlib ipython-notebook