confused about behavior inside and outside ipython

I have googled around and looked through the documents, but I can't
seem to find a description of the difference between running a script
inside and outside ipython (using ipython --pylab). For example, I
tried doing the following in a script and made it executable.

#!/usr/bin/python

from __future__ import print_function
import matplotlib.pyplot as plt

for a in xrange(0,2):
        print(a)
        plt.plot([1,2,3,4])
        plt.show()

In ipython, it just prints 0 and 1 and shows one figure then stops.
Outside ipython, for example just running from the command line, it
prints 0, shows a plot, and stops to wait for me to close the plot.
Then it prints one and shows a second plot (which is the behavior I am
looking for).

My question is how to I get the script to behave the same (as if I ran
it fro the command line) both inside and outside ipython? If it isn't
possible directly, is there a way to pause execution in ipython to wait
until I close the plot before showing the next?

Thanks!

-C

I have googled around and looked through the documents, but I can't
seem to find a description of the difference between running a script
inside and outside ipython (using ipython --pylab). For example, I
tried doing the following in a script and made it executable.

#!/usr/bin/python

from __future__ import print_function
import matplotlib.pyplot as plt

for a in xrange(0,2):
         print(a)
         plt.plot([1,2,3,4])
         plt.show()

In ipython, it just prints 0 and 1 and shows one figure then stops.
Outside ipython, for example just running from the command line, it
prints 0, shows a plot, and stops to wait for me to close the plot.
Then it prints one and shows a second plot (which is the behavior I am
looking for).

My question is how to I get the script to behave the same (as if I ran
it fro the command line) both inside and outside ipython? If it isn't
possible directly, is there a way to pause execution in ipython to wait
until I close the plot before showing the next?

Colin,

I think you will find that with mpl from svn, the behavior is as you wish, and the same in or out of ipython (version 0.10 or higher).

Eric

···

On 10/06/2010 06:18 PM, Collin Day wrote:

Thanks!

-C

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options