Skip to content

Commit

Permalink
Merge pull request #27481 from shriyakalakata/pylab_docs
Browse files Browse the repository at this point in the history
Fixing Pylab documentation in API interface overview
  • Loading branch information
timhoffm committed Dec 9, 2023
2 parents da1d766 + 6c2b5ad commit 444d042
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions galleries/users_explain/figure/api_interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ Appendix: "pylab" interface
---------------------------

There is one further interface that is highly discouraged, and that is to
basically do ``from matplotlib.pyplot import *``. This allows users to simply
call ``plot(x, y)``. While convenient, this can lead to obvious problems if the
user unwittingly names a variable the same name as a pyplot method.
basically do ``from matplotlib.pylab import *``. This imports all the
functions from ``matplotlib.pyplot``, ``numpy``, ``numpy.fft``, ``numpy.linalg``, and
``numpy.random``, and some additional functions into the global namespace.

Such a pattern is considered bad practice in modern python, as it clutters
the global namespace. Even more severely, in the case of ``pylab``, this will
overwrite some builtin functions (e.g. the builtin ``sum`` will be replaced by
``numpy.sum``), which can lead to unexpected behavior.

0 comments on commit 444d042

Please sign in to comment.