Hi,
I think I have a Mac OS X specific problem using 'ipython -pylab'
I have some pylab plotting that updates for every event on ubuntu with the wxpython backend.
However, the same code on OS X does not update until the final pylab.show().
However, when I enter a series of plot commands from the ipython prompt, they update fine.
I'm presuming it's some kind of threading problem, so my question is; is there a way to explicitly give app.mainloop() or whatever some oxygen?
Here's the example code which updates each plot separately as expected/desired under ubuntu +python2.4 + wxPython2.6 + ipython 0.6.x, matplotlib-0.86.2
Under Mac OS 10.4 + python 2.4.1 + wxpython2.6 + ipython 0.7.1.fix1 (didn't work for ipython 0.6.x either) + matplotlib-0.86.2cvs-py2.4-macosx-10.4-ppc.egg, the update does not occur until the pylab.show() statement is reached (and yes, I tried replacing the draw with show, no difference).
It was a lot faster when I removed the pylab.draw() statement, so the rendering would seem to be taking place, it just doesn't make it to the physical screen.
Have any other Mac OS X users experienced this? Any suggestions?
regards,
Graeme
% ipython -pylab
In [1]:import interactive as i
In [2]:i.main()
isinteractive() = True
here is interactive.py
#!/usr/bin/env python
···
#
# ipython -pylab
# In [1]: import interactive as i
# In [2]: i.main()
#
import pylab, numpy
class data :
def __init__(self, N) :
self.n = 0
self.N = N
self.t = numpy.arange(0.0, 2*numpy.pi, numpy.pi / 64)
#end
def read(self) :
self.n += 1
self.y = numpy.sin(self.t) + numpy.randn(len(self.t))/10.0
if self.n >= self.N : return False
else : return True
#end
#end
def main(N = 100) :
print 'isinteractive() = ', pylab.interactive()
d = data(N)
f = pylab.figure()
a = f.add_subplot(1,1,1)
cols = 'rgbcmyk'
n = 0
while d.read() :
# a.hold(False)
a.plot(d.t, d.y, cols[n % len(cols)])
a.grid(True)
pylab.draw()
n += 1
#end
pylab.show()
#end
if __name__ == '__main__' :
main(10)
#end