2013-10-19 3 views
1

나 인생에서 iPython에 애니메이션 플롯을 표시 할 수 없다. 이 코드는 matplotlib 애니메이션 예제에서 직접 가져온 것으로 일반 오래된 파이썬 (일명 python animate.py)을 사용하여 잘 작동합니다. ipython --pylab auto animate.py와 전화iPython + pylab/matplotlib 애니메이션 기다림

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 tk animate.py 모두 윈도우가 즉시 사라지는 원인이된다. ion()plt.draw()의 주석을 제거하면 프레임 하나가 그려지고 중단됩니다. iPython은 일반적인 matplotlib 구현보다 스레드로부터 안전하기 때문에 사용해야합니다.

내가 뭘 잘못하고 있니? iPython 1.1 OSX 10.8에 python2.7.2를 사용하여 1.3

답변

1

위하기 matplotlib - 헛수 주석을 해제하지 않고 단지와 함께 잘 작동 :

ipython --pylab=auto 

In [1]: import animate 

그래서 내가 문제라고 생각 그렇게

ipython animate.py 

백엔드 선택이 중요한 대화 형 모드를 상호 작용없이 연속적으로 실행되는 스크립트와 결합하려고합니다. 이는 충돌입니다.

문서 읽기 herehereIPython.lib.inputhook.InputHookManager으로 전화하여 animate.py으로 전화하여 백엔드를 설정해야 할 것으로 판단됩니다.

IPython 0.13.2하기 matplotlib '1.3.0'쿠분투 13.10

+0

안녕하세요, 스티브, - pylab 스위치를 사용하지 않으면, (afaik 어쨌든) 사용에 관심이있는 ipython 백엔드를 활성화하지 않습니다. – jeremy

0

나도이를 시도하고있다. 대부분의 사용자는 Jake Vanderplaas의 JSAnimation을 사용합니다. 링크. https://github.com/jakevdp/JSAnimation. 그러나 이것은 Enthought 배포판에있는 패키지가 아니며 별도로 가져올 필요성을 나타냅니다.