Skip to content

Commit

Permalink
Move pylab documentation to its own module page
Browse files Browse the repository at this point in the history
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
  • Loading branch information
timhoffm committed Jul 26, 2023
1 parent 6fba64a commit 21864d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
7 changes: 1 addition & 6 deletions doc/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ Further reading:

.. _api-index:

The pylab API (discouraged)
^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automodule:: pylab
:no-members:

Modules
-------

Expand Down Expand Up @@ -162,3 +156,4 @@ Alphabetical list of modules:
toolkits/mplot3d.rst
toolkits/axes_grid1.rst
toolkits/axisartist.rst
pylab.rst
6 changes: 6 additions & 0 deletions doc/api/pylab.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*********
``pylab``
*********

.. automodule:: pylab
:no-members:
23 changes: 14 additions & 9 deletions lib/matplotlib/pylab.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""
`pylab` is a historic interface that is no longer recommended.
Its original purpose was to mimic a MATLAB-like way of working by importing all
functions into the global namespace.
The intended usage pattern was ``from pylab import *``. This imports all functions
from `matplotlib.pyplot`, `numpy`, `numpy.fft`, `numpy.linalg`, `numpy.random`, and
some additional functions into the global namespace.
.. warning::
Since heavily importing into the global namespace may result in unexpected
behavior, the use of pylab is strongly discouraged. Use `matplotlib.pyplot`
instead.
`pylab` is a module that includes `matplotlib.pyplot`, `numpy`, `numpy.fft`,
`numpy.linalg`, `numpy.random`, and some additional functions, all within
a single namespace. Its original purpose was to mimic a MATLAB-like way
of working by importing all functions into the global namespace. This is
considered bad style nowadays.
The wildcard import will overwrite some builtin functions (e.g. the builtin `sum`
will be replaced by `numpy.sum`). This can lead to unexpected behavior.
The use of pylab is strongly discouraged. Use `matplotlib.pyplot` instead.
"""

from matplotlib.cbook import flatten, silent_list
Expand Down

0 comments on commit 21864d1

Please sign in to comment.