Menu

[r7401]: / branches / mathtex / examples / animation / gtk_timeout.py  Maximize  Restore  History

Download this file

20 lines (15 with data), 449 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import gobject
import numpy as np
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1)
def update():
line.set_ydata(np.random.rand(10))
fig.canvas.draw_idle()
return True # return False to terminate the updates
gobject.timeout_add(100, update) # you can also use idle_add to update when gtk is idle
plt.show()