Revision: 5854
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5854&view=rev
Author: jdh2358
Date: 2008-07-24 22:34:32 +0000 (Thu, 24 Jul 2008)
Log Message:
-----------
fixed anim.py to use tk idiom
Modified Paths:
--------------
trunk/matplotlib/examples/animation/anim.py
Modified: trunk/matplotlib/examples/animation/anim.py
===================================================================
--- trunk/matplotlib/examples/animation/anim.py 2008-07-24 22:29:57 UTC (rev
5853)
+++ trunk/matplotlib/examples/animation/anim.py 2008-07-24 22:34:32 UTC (rev
5854)
@@ -1,32 +1,24 @@
#!/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
+A simple example of an animated plot in tkagg
"""
-import time
+import matplotlib
+matplotlib.use('TkAgg') # do this before importing pylab
-import pylab as p
+import matplotlib.pyplot as plt
+fig = plt.figure()
+ax = fig.add_subplot(111)
-# turn interactive mode on for dynamic updates. If you aren't in
-# interactive mode, you'll need to use a GUI event handler/timer.
-p.ion()
+def animate():
+ tstart = time.time() # for profiling
+ x = np.arange(0, 2*np.pi, 0.01) # x-array
+ line, = ax.plot(x, np.sin(x))
-tstart = time.time() # for profiling
-x = p.arange(0, 2*p.pi, 0.01) # x-array
-line, = p.plot(x, p.sin(x))
-for i in p.arange(1,200):
- line.set_ydata(p.sin(x+i/10.0)) # update the data
- p.draw() # redraw the canvas
+ for i in np.arange(1,200):
+ line.set_ydata(np.sin(x+i/10.0)) # update the data
+ fig.canvas.draw() # redraw the canvas
+ print 'FPS:' , 200/(time.time()-tstart)
-print 'FPS:' , 200/(time.time()-tstart)
+win = fig.canvas.manager.window
+fig.canvas.manager.window.after(100, animate)
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins