graph for streaming data in gtk+


I'm searching for a method to show a stream of data on a graph. So far
I've only managed to get the stream on a regular graph but the data
bandwidth is very high (100 samples/sec) and the usual graph doesn't
handle redrawing so good.

I was searching for a way to utilize the animation functionality of
matplotlib but found only some Tk examples (with very smooth refresh

But I couldn't modify the source to create the same effect using the Gtk
+ front-end. The problem is that I don't know how to integrate the graph
into the Glib main loop.

Please help.

This is an example I found o the net:


import matplotlib
matplotlib.use('TkAgg') # do this before importing pylab
import matplotlib.pyplot as plt
import random

fig = plt.figure()
ax = fig.add_subplot(111)

x = range(30)
y = [random.random() for i in x]
line, = ax.plot(x,y)

def animate(*args):
    n = len(y)
    while True:
        data = random.random()

        n += 1
        line.set_data(range(n-30, n), y[-30:])
        ax.set_xlim(n-31, n-1)

fig.canvas.manager.window.after(100, animate)