Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21864d1

Browse files
committed
Move pylab documentation to its own module page
Previously, pylab was not listed under modules, but the module docstring (and thus also the target of pylab links) wa on the API Reference top page. While pylab is discouraged, it's still a regular module and should be handled as such. Even more importantly, by removing the pylab section from the API reference top page, we de-emphasize it. Note, that pylab is still mentioned in the more in-depth backend discussion at https://matplotlib.org/devdocs/users/explain/figure/api_interfaces.html
1 parent 6fba64a commit 21864d1

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

doc/api/index.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ Further reading:
8080

8181
.. _api-index:
8282

83-
The pylab API (discouraged)
84-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
85-
86-
.. automodule:: pylab
87-
:no-members:
88-
8983
Modules
9084
-------
9185

@@ -162,3 +156,4 @@ Alphabetical list of modules:
162156
toolkits/mplot3d.rst
163157
toolkits/axes_grid1.rst
164158
toolkits/axisartist.rst
159+
pylab.rst

doc/api/pylab.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*********
2+
``pylab``
3+
*********
4+
5+
.. automodule:: pylab
6+
:no-members:

lib/matplotlib/pylab.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
"""
2+
`pylab` is a historic interface that is no longer recommended.
3+
4+
Its original purpose was to mimic a MATLAB-like way of working by importing all
5+
functions into the global namespace.
6+
7+
The intended usage pattern was ``from pylab import *``. This imports all functions
8+
from `matplotlib.pyplot`, `numpy`, `numpy.fft`, `numpy.linalg`, `numpy.random`, and
9+
some additional functions into the global namespace.
10+
211
.. warning::
3-
Since heavily importing into the global namespace may result in unexpected
4-
behavior, the use of pylab is strongly discouraged. Use `matplotlib.pyplot`
5-
instead.
6-
7-
`pylab` is a module that includes `matplotlib.pyplot`, `numpy`, `numpy.fft`,
8-
`numpy.linalg`, `numpy.random`, and some additional functions, all within
9-
a single namespace. Its original purpose was to mimic a MATLAB-like way
10-
of working by importing all functions into the global namespace. This is
11-
considered bad style nowadays.
12+
The wildcard import will overwrite some builtin functions (e.g. the builtin `sum`
13+
will be replaced by `numpy.sum`). This can lead to unexpected behavior.
14+
15+
The use of pylab is strongly discouraged. Use `matplotlib.pyplot` instead.
16+
1217
"""
1318

1419
from matplotlib.cbook import flatten, silent_list

0 commit comments

Comments
 (0)