re freshing plot in loop

My program runs through a loop and is supposed to re-plot the graph after
each step (which includes a pause of 1 second). I can't get the plot to
refresh. I wrote the following simple program which has the same problem. I
tried both draw() nor f.canvas.draw() works. I'm running it from ipython
-pylab

A similar problem was encountered here:
http://www.nabble.com/Plotting-loop-refuses-to-update-display-on-OS-X-td19818020.html
but I still don't know what to do.

### teststuff.py

import pylab
import time

def testRef():
    f = pylab.figure()
    ax = pylab.gca()
    pylab.show()
    for x in range(10):
        ax.axhline(x)
        time.sleep(1)
# pylab.draw()
        f.canvas.draw()
        
testRef()

···

--
View this message in context: http://www.nabble.com/refreshing-plot-in-loop-tp20122473p20122473.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

joschu wrote:

My program runs through a loop and is supposed to re-plot the graph after
each step (which includes a pause of 1 second). I can't get the plot to
refresh. I wrote the following simple program which has the same problem. I
tried both draw() nor f.canvas.draw() works. I'm running it from ipython
-pylab

Animation in mpl is a bit tricky. Have you checked out the examples in the examples/animation subdirectory of the current version? See also http://www.scipy.org/Cookbook/Matplotlib/Animations

Eric

···

A similar problem was encountered here:
http://www.nabble.com/Plotting-loop-refuses-to-update-display-on-OS-X-td19818020.html
but I still don't know what to do.

### teststuff.py

import pylab
import time

def testRef():
    f = pylab.figure()
    ax = pylab.gca()
    pylab.show()
    for x in range(10):
        ax.axhline(x)
        time.sleep(1)
# pylab.draw()
        f.canvas.draw()
        testRef()

I wasn't aware of those examples. I tried the first one and again it didn't
refresh.
I was able to get things working by switching my backend to Tcl. Previously
I was using wxpython, and I think there was a problem in the installation.

efiring wrote:

···

joschu wrote:

My program runs through a loop and is supposed to re-plot the graph after
each step (which includes a pause of 1 second). I can't get the plot to
refresh. I wrote the following simple program which has the same problem.
I
tried both draw() nor f.canvas.draw() works. I'm running it from ipython
-pylab

Animation in mpl is a bit tricky. Have you checked out the examples in
the examples/animation subdirectory of the current version? See also
http://www.scipy.org/Cookbook/Matplotlib/Animations

Eric

A similar problem was encountered here:
http://www.nabble.com/Plotting-loop-refuses-to-update-display-on-OS-X-td19818020.html
but I still don't know what to do.

### teststuff.py

import pylab
import time

def testRef():
    f = pylab.figure()
    ax = pylab.gca()
    pylab.show()
    for x in range(10):
        ax.axhline(x)
        time.sleep(1)
# pylab.draw()
        f.canvas.draw()
        
testRef()

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://www.nabble.com/refreshing-plot-in-loop-tp20122473p20143650.html
Sent from the matplotlib - users mailing list archive at Nabble.com.