我一辈子都不能让伊普顿演动画片。这段代码直接取自matplotlib动画示例,使用普通的python(akapython animate.py
)可以很好地工作。在
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1)
def update(data):
line.set_ydata(data)
return line,
def data_gen():
while True: yield np.random.rand(10)
ani = animation.FuncAnimation(fig, update, data_gen, interval=100)
#plt.ion()
plt.show()
#while 1:
#plt.draw()
用ipython --pylab auto animate.py
调用,ipython --pylab tk animate.py
都会导致窗口立即消失。如果我取消对ion()
和plt.draw()
的注释,它只会绘制一个帧,然后挂起。我需要使用iPython,因为它比普通的matplotlib实现更安全。在
我做错什么了?在带有iPython 1.1和matplotlib 1.3的osx10.8上使用python2.7.2
我也试过这个。似乎大多数用户都使用Jake Vanderplaas的JSAnimation。链接。https://github.com/jakevdp/JSAnimation。然而,这并不是热情发行版中的一个软件包,因此需要单独进口。在
以上-无需取消注释anythin,只需:
是的
^{pr2}$所以我认为你的问题是你试图将交互模式与一个没有交互的连续运行的脚本相结合,这是一个冲突。在
阅读文档here和{a2}我怀疑您需要调用
animate.py
中的IPython.lib.inputhook.InputHookManager
来设置后端。在IPython 0.13.2 matplotlib'1.3.0'kubuntu 13.10
相关问题 更多 >
编程相关推荐