pylab: plot update

Discussion in 'Python' started by Jan Wienhausen, May 11, 2005.

  1. 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
     
    Jan Wienhausen, May 11, 2005
    #1
    1. Advertisements

  2. 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
     
    Skip Montanaro, May 11, 2005
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.