我在OS X上并使用Encopy(由Enthought inc。编写)来编写我的python程序。我把它从here下面的代码只生成一个点,然后它终止:Matplotlib交互式环境不起作用
from pylab import *
import time
t = linspace(0.0, pi, 100)
x = cos(t)
y = sin(t)
ion() # turn on interactive mode
figure(0)
subplot(111, autoscale_on=False, xlim=(-1.2, 1.2), ylim=(-.2, 1.2))
point = plot([x[0]], [y[0]], marker='o', mfc='r', ms=3)
for j in arange(len(t)):
# reset x/y-data of point
setp(point[0], data=(x[j], y[j]))
time.sleep(0.05)
draw() # redraw current figure
ioff() # turn off interactive mode
show()
任何想法可能是什么问题? 下面是我得到的结果的照片。
使用'plt.pause'取代'sleep' – tacaswell
@tcaswell,谢谢。但还是单点! – Cupitor