Plot updating from file

Hey guys,
I'm very new to python and matplotlib (in fact all programing) and I've been
trying to figure out a way to plot a series of data that's saved to a file.
I'd like for there to be some delay when the plot refreshes too, so maybe
like 1-2 seconds.

The file looks something like this

0 0 10 10 20 30 20 10 0 0
10 10 20 30 10 10 10 10 0 0
0 0 10 10 20 30 20 10 0 0

etc, but has 120 values, and obviously, the numbers after the 1000 is what i
wish to plot. Playing around with matplotlib i found that it plots files
that are written as

so my code incorporates a way to read one line, transpose it, and then plot
but then i'd like some delay, and the plot is then refreshed with the next
sequence of data, and this to go on until i run out of data.

My code:
import linecache
import matplotlib.pyplot as plt
import os

while i < 7:
    g = linecache.getline('data.txt', i)
    g =g.replace(" ","\n")
    filename = "test.txt"
    file = open(filename, 'w')
    i = i+2

I know it must seem horribly inefficient, but when i run it, it doesn't
update it, just opens more than one plot and plots each one (and usually

Any advice would be fantastic.
Thanks, Anthony


View this message in context:
Sent from the matplotlib - users mailing list archive at