On Sat, 12 Apr 2008, Alan G Isaac apparently wrote:
> 1. Running anim.py at DOS prompt: it runs correctly until
> the end:
> Fatal Python error: PyEval_RestoreThread: NULL tstate
OK, there is a simple fix to this:
explicitly close the figure after the loop.
I'll attach a fixed example file, in case
a developer cares to substitute it.
New question 1: why is this necessary?
New question 2: why can I tab away from the Tk Window
while this script is running but not tab back to it?
Old question remaining:
Running under the Python interpreter (using execfile): The
Tk window will not display until the script has finished
running, so the animation cannot be viewed. How can I run
this animation from the interpreter window?
Note that this seems closely related to New Question 2.
Thank you,
Alan Isaac
#!/usr/bin/env python
"""
A simple example of an animated plot in matplotlib. You can test the
speed of animation of various backends by running the script with the
'-dSomeBackend' flag
SC Aug 31 2005 mpl 0.83.2:
Here are some numbers from my system, where FPS is the frames rendered
per second
GTK 29 FPS
GTKAgg 18 FPS
GTKCairo 15 FPS
TkAgg 13 FPS
QkAgg 13 FPS
"""
import time
import pylab as plt
# turn interactive mode on for dynamic updates. If you aren't in
# interactive mode, you'll need to use a GUI event handler/timer.
plt.ion()
fig1 = plt.figure(1)
ax1 = fig1.gca()
tstart = time.time() # for profiling
x = plt.arange(0, 2*plt.pi, 0.01) # x-array
line, = ax1.plot(x, plt.sin(x))
for i in plt.arange(1,20):
line.set_ydata(plt.sin(x+i/10.0)) # update the data
plt.draw() # redraw the canvas
plt.close(fig1)
print 'FPS:' , 200/(time.time()-tstart)
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users