Skip to content

Commit eb001d1

Browse files
committed
Merge pull request #3743 from Carreau/nopylab
DOC : remove mention to %pylab
1 parent d1ffdd0 commit eb001d1

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

doc/users/image_tutorial.rst

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,28 @@ Image tutorial
1010
Startup commands
1111
===================
1212

13-
At the very least, you'll need to have access to the
14-
:func:`~matplotlib.pyplot.imshow` function. There are a couple of
15-
ways to do it. The easy way for an interactive environment::
16-
13+
In this tutorial we will work interactively with images. To do so we will use
14+
the IPython shell. You can start it with::
15+
1716
$ipython
1817

19-
to enter the ipython shell, followed by::
20-
21-
In [1]: %pylab
22-
23-
to enter the pylab environment.
24-
25-
The imshow function is now directly accessible (it's in your
26-
`namespace <http://bytebaker.com/2008/07/30/python-namespaces/>`_).
27-
See also :ref:`pyplot-tutorial`.
28-
29-
The more expressive, easier to understand later method (use this in
30-
your scripts to make it easier for others (including your future self)
31-
to read) is to use the matplotlib API (see :ref:`artist-tutorial`)
32-
where you use explicit namespaces and control object creation, etc...
18+
At the very least, you'll need to have access to the
19+
:func:`~matplotlib.pyplot.imshow` function. The easy way for an interactive
20+
environment: is to use the matplotlib API (see :ref:`artist-tutorial`) where
21+
you use explicit
22+
`namespaces <http://bytebaker.com/2008/07/30/python-namespaces/>`_ and control
23+
object creation, etc...::
3324

3425
.. sourcecode:: ipython
3526

3627
In [1]: import matplotlib.pyplot as plt
3728
In [2]: import matplotlib.image as mpimg
3829
In [3]: import numpy as np
3930

40-
Examples below will use the latter method, for clarity. In these
41-
examples, if you use the %pylab method, you can skip the "mpimg." and
42-
"plt." prefixes.
31+
You can now access functions like :func:`~matplotlib.pyplot.imshow` by using:
32+
`plt.imshow(yourimage)`. You can learn more about these functions in the
33+
:ref:`pyplot-tutorial`.
34+
4335

4436
.. _importing_data:
4537

doc/users/shell.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,19 @@ python shell.
2020

2121
.. _ipython-pylab:
2222

23-
Ipython to the rescue
23+
IPython to the rescue
2424
=====================
2525

26+
.. note::
27+
28+
The mode described here still exists for historical reasons, but it is
29+
highly advised not to use. It pollutes namespaces with functions that will
30+
shadow python built-in and can lead to hard to track bugs. To get IPython
31+
integration without imports the use of the `%matplotlib` magic is
32+
preferred. See
33+
`ipython documentation <http://ipython.org/ipython-doc/stable/interactive/reference.html#plotting-with-matplotlib>`_
34+
.
35+
2636
Fortunately, `ipython <http://ipython.org/>`_, an enhanced
2737
interactive python shell, has figured out all of these tricks, and is
2838
matplotlib aware, so when you start ipython in the *pylab* mode.

0 commit comments

Comments
 (0)