pyplot vs pylab?

Hi folks,

I've added this little bit of code to the default ipython -pylab startup:

        exec ("import numpy\n"
              "import numpy as np\n"
              "import matplotlib\n"
              "import matplotlib.pylab as pylab\n"
              "try:\n"
              " import matplotlib.pyplot as plt\n"
              "except ImportError:\n"
              " pass\n"
              ) in user_ns

to try and encourage use of the 'canonical' ways of calling/executing
numpy and mpl calls. This is just in my branch, not publicly visible
yet. I wanted to know:

1. If I should keep the try/except around.
2. If this is your 'approved' manner of loading. It worries me a bit
that if we promote pyplot/plt as the entry point, it needs a proper
docstring. Just try 'pylab?' vs 'pyplot?' and you'll see the
difference.

Cheers,

f

I've added this little bit of code to the default ipython -pylab startup:

The latest releases of pylab already provide np and plt in the pylab namespace.

Would it be better to simply add a "pyplot" mode to ipython to
encourage the proper usage, and in this mode import only as few
symbols (np, plt, and sp if possible)?

it needs a proper docstring. Just try 'pylab?' vs 'pyplot?'

We can easily add the docstring for the next bug fix release

JDH

···

On Mon, Jun 2, 2008 at 3:26 AM, Fernando Perez <fperez.net@...149...> wrote:

I'm not sure the duplication is worthwhile (users don't read mailing
lists on weekends, you know? They have lives and all that :slight_smile:
Besides, for ipython the 'import *' mode *is* a reasonable use case,
since when you're working interactively, you really just want to type

plot(x,cos(x**2)+sin(x**3))

and not some plt.foo/np.bar contraption. So I think there remains a
use case for importing all the names in at the top level (remember
that you can configure now ipython to NOT do 'from pylab import *'
anymore if you reall want a clean namespace).

The use case is mostly to provide an environment where the standard
examples and docstrings that may use either numpy or np,
pylab/pyplot/plt are always defined, so users can copy/paste without
fear.

Cheers,

f

···

On Mon, Jun 2, 2008 at 7:28 AM, John Hunter <jdh2358@...149...> wrote:

On Mon, Jun 2, 2008 at 3:26 AM, Fernando Perez <fperez.net@...149...> wrote:

I've added this little bit of code to the default ipython -pylab startup:

The latest releases of pylab already provide np and plt in the pylab namespace.

Would it be better to simply add a "pyplot" mode to ipython to
encourage the proper usage, and in this mode import only as few
symbols (np, plt, and sp if possible)?