I've followed up on several suggestions and here is what I've done/found. (I know I don't use mlab or pylab but I pulled the import lines from another source and am leaving them in for the heck of it)
Code A: import numpy as np import matplotlib import time from matplotlib import pylab, mlab, pyplot A = np.random.rand(5,5,10) for j in range(10): pyplot.matshow(A[:,:,j]) # pyplot.pause(.5) pyplot.show() time.sleep(0.5) pyplot.close() Code B: import numpy as np import matplotlib import time from matplotlib import pylab, mlab, pyplot A = np.random.rand(5,5,10) for j in range(10): pyplot.matshow(A[:,:,j]) pyplot.pause(.5) # pyplot.show() # time.sleep(0.5) pyplot.close() ================ 1) Code A: Spyder Python (Mac) - A blank figure window is generated, closed, and repeated over ten iterations. No user intervention needed to allow loop to continue. Adding a pyplot.ioff() line after the from matplotlib line gives the expected/hoped behavior: Ten arrays appear, one after the other, no intervention needed. --- Ipython Notebook (no --pylab) - A figure window with an array appears. I have to close it using the Window Close titlebar button, then the next one appears, waits for close action, etc. Adding a pyplot.ion() statement after the from matplotlib line yields the same result as Spyder Python w/o the pyplot.ioff() line. 10 blank windows appear one after the other. Code B: Spyder Python and Ipython Notebook (no --pylab) - Both display expected/hoped behavior. Figure window appears, figure displays, closes, and then opens with next piece of data So, there's something about the pause command that's special, at least in this case, and I'd like to understand what that is. 2) Additional interactive test following code runs: pyplot.matshow(A[:,:,6)] Spyder Python - Figure pops up, plot is displayed. Zoom, pan, back/forth, home buttons all work Ipython notebook (no --pylab) - Figure pops up, no plot displays. Adding pause(x) causes figure to display. Plot is interactive for x seconds. Zoom, pan, etc. work for that time. Notebook shows In[*] for x seconds. After x seconds, In[*] <-- In[Cell number]. Plot is no longer interactive, mousing over plot shows spinning Mac rainbow ball. Can't even close window using titlebar icons. pyplot.close() from a cell required to close. I would like to stay with the Notebook as I learn matplotlib but I'm not sure how to get around the plot being interactive for only a defined time period, spinning rainbow balls, etc. JBB On 7/30/14, 9:30 AM, Benjamin Root wrote: > I think it is mostly an issue with how IPython interfaces with > matplotlib. If you were running from a pure python prompt, then I would > suspect it to work (haven't tried myself, though). Note that the --pylab > option to ipython is now highly discouraged. Instead, I would try the > "%matplotlib interactive" cell magic instead (I think that is the right > incantation). > > > On Wed, Jul 30, 2014 at 2:15 AM, JBB > <jeanbigbo...@gmail.com > <mailto:jeanbigbo...@gmail.com>> wrote: > > On 7/29/14, 10:49 PM, Eric Firing wrote: > > On 2014/07/29, 7:04 PM, JBB wrote: > >> Hello, > >> > >> I am relatively new to Python, numpy, matplotlib, etc., with a > >> reasonable amount of Matlab experience. > > ...[ Problem and test code trimmed ] > > > > > First, at least initially for this sort of thing, run in "ipython > > --pylab", and don't use any "ion()" or "ioff()". > > > > Second, replace the "show(); time.sleep(1)" with "pause(1)". > > > > I think that will do it. > > > > Eric > > > > Thank you, very much. It did indeed work. > > Is there a pointer to why this worked when my initial approach did not? > I thought from the documentation/videos that preparing a plot with > relevant commands then issuing the show() command was the preferred > approach within Python/Matplotlib. > > JBB > > > > > > ------------------------------------------------------------------------------ > Infragistics Professional > Build stunning WinForms apps today! > Reboot your WinForms applications with our WinForms controls. > Build a bridge from your legacy apps to the future. > > http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > <mailto:Matplotlib-users@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > ------------------------------------------------------------------------------ > Infragistics Professional > Build stunning WinForms apps today! > Reboot your WinForms applications with our WinForms controls. > Build a bridge from your legacy apps to the future. > http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users