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

1000
0 0 10 10 20 30 20 10 0 0
1000
10 10 20 30 10 10 10 10 0 0
1000
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
0
0
10
10
etc

so my code incorporates a way to read one line, transpose it, and then plot
it.
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

i=3
while i < 7:
    g = linecache.getline('data.txt', i)
    g =g.replace(" ","\n")
    filename = "test.txt"
    file = open(filename, 'w')
    file.write(g)
    file.close()
    plt.plotfile("test.txt")
    plt.show()
    os.remove("test.txt")
    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
crashes)

Any advice would be fantastic.
Thanks, Anthony

···

--
View this message in context: http://www.nabble.com/Plot-updating-from-file-tp25001050p25001050.html
Sent from the matplotlib - users mailing list archive at Nabble.com.