Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > dc303dcad9fdd039290b4e78a58ed938 > files > 466

python-matplotlib-0.99.1.2-4.fc13.i686.rpm

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()