pylab: plot update

J

Jan Wienhausen

Hi,
I need to do a plot of data that is beeing acuired. For that the plot
needs to be updated after aquiering a new tuple.
At the moment I allways do this after a new tuple is aqcuired:

plot(ar[0,i-1:i],br[1,i-1:i],'ro')
show()
#ar is arrays were the new tuple is put in position [0,i] and [1,i]

After that i call sleep(5) until I can acuire the next tuple.
But during that I can't use the zoom/pan, save etc in the window.

Moreover the first time I call plot and show the first point is drawn
correctly but I have to close the window otherwise the program does not
run any further. But after closing the window ones it runs without any
problems.

Is there any better way to do this easily?

Thanks,
Jan
 
S

Skip Montanaro

Jan> After that i call sleep(5) until I can acuire the next tuple.
Jan> But during that I can't use the zoom/pan, save etc in the window.

...

Jan> Is there any better way to do this easily?

Set a timeout. How to do that depends on what gui tools you are using.
I've never used pylab so I don't know how it integrates with the rest of
your app.

If you're using PyGTK, something like this should suffice:

gobject.timeout_add(5000, update_plot)

where the update_plot function executes your acquisition/plot code. It
needs to return True if you want it to be triggered every five seconds,
otherwise it's a one-shot.

Skip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top