Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent db72044 commit 135692cCopy full SHA for 135692c
1 file changed
examples/animation/simple_anim_gtk.py
@@ -0,0 +1,30 @@
1
+"""
2
+A simple example of an animated plot using a gtk backends
3
4
+import time
5
+import numpy as np
6
+import matplotlib
7
+matplotlib.use('GTKAgg') # do this before importing pylab
8
+
9
+import matplotlib.pyplot as plt
10
11
+fig = plt.figure()
12
13
+ax = fig.add_subplot(111)
14
15
+def animate():
16
+ tstart = time.time() # for profiling
17
+ x = np.arange(0, 2*np.pi, 0.01) # x-array
18
+ line, = ax.plot(x, np.sin(x))
19
20
+ for i in np.arange(1,200):
21
+ line.set_ydata(np.sin(x+i/10.0)) # update the data
22
+ fig.canvas.draw() # redraw the canvas
23
+ print 'FPS:' , 200/(time.time()-tstart)
24
+ raise SystemExit
25
26
+import gobject
27
+print 'adding idle'
28
+gobject.idle_add(animate)
29
+print 'showing'
30
+plt.show()
0 commit comments