Revision: 5857
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5857&view=rev
Author:   jdh2358
Date:     2008-07-24 22:41:52 +0000 (Thu, 24 Jul 2008)

Log Message:
-----------
added simple gtk animation example

Added Paths:
-----------
    trunk/matplotlib/examples/animation/simple_anim_gtk.py

Added: trunk/matplotlib/examples/animation/simple_anim_gtk.py
===================================================================
--- trunk/matplotlib/examples/animation/simple_anim_gtk.py                      
        (rev 0)
+++ trunk/matplotlib/examples/animation/simple_anim_gtk.py      2008-07-24 
22:41:52 UTC (rev 5857)
@@ -0,0 +1,30 @@
+"""
+A simple example of an animated plot using a gtk backends
+"""
+import time
+import numpy as np
+import matplotlib
+matplotlib.use('GTKAgg') # do this before importing pylab
+
+import matplotlib.pyplot as plt
+
+fig = plt.figure()
+
+ax = fig.add_subplot(111)
+
+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))
+
+    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)
+    raise SystemExit
+
+import gobject
+print 'adding idle'
+gobject.idle_add(animate)
+print 'showing'
+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
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to