Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Pylab documentation in API interface overview #27481

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.