Skip to content

Commit 8003178

Browse files
committed
Restructure interface section API Reference index page
- switch to Axes interface / pyplot interface terminology (matplotlib#26388) - Reduce the interface description to very compact two-sentence descriptions and refer to the interface page for everything else. The focus here is to point the users to relevant API resources for the respective interfaces, not to discuss these interfaces in detail. The latter is the task of https://matplotlib.org/devdocs/users/explain/figure/api_interfaces.html and I will add some missing pieces there in a follow-up PR.
1 parent 40d2761 commit 8003178

File tree

3 files changed

+20
-40
lines changed

3 files changed

+20
-40
lines changed

doc/api/axes_api.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _matplotlib-axes:
2-
31
*******************
42
``matplotlib.axes``
53
*******************

doc/api/index.rst

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,65 +41,47 @@ Matplotlib provides two different interfaces:
4141
- Within the *Axes interface* you create a Figure and one or more Axes objects
4242
(typically using `.pyplot.subplots`). Then, you use methods on these objects to add
4343
data, configure limits, set labels etc.
44-
- The *pyplot interface* consists of functions that make changes
44+
- The *pyplot interface* consists of functions. Figure and Axes are manipulated through
45+
these functions and are only implicitly present in the background.
4546

4647
See :ref:`api_interfaces` for a more detailed description of both and their recommended
4748
use cases.
4849

49-
.. grid:: 2
50+
.. grid:: 1 1 2 2
51+
:padding: 0 0 1 1
5052

51-
.. grid-item-card:: ``Axes`` interface
53+
.. grid-item-card::
54+
55+
**Axes interface** (object-based, explicit)
56+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5257

5358
API:
5459

55-
- `~matplotlib.figure.Figure`: configure all figure related settings
56-
- :ref:`Axes <matplotlib-axes>`: add data, configure limits, set labels etc.
60+
- `~.pyplot.subplots`: create Figure and Axes
61+
- :doc:`Axes </api/axes_api>` add data, limits, labels etc.
62+
- :doc:`Figure <figure_api>` for figure-level methods
5763

5864
Examples:
5965

60-
- Most of the :ref:`examples <examples-index>` use this
66+
- Most :ref:`examples <examples-index>` use this
67+
6168
(except for the pyplot section)
6269

63-
.. grid-item-card:: ``pyplot`` interface
70+
.. grid-item-card::
71+
72+
**pyplot interface** (function-based, implicit)
73+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6474

6575
API:
6676

67-
- `matplotlib.pyplot` function reference
77+
- `matplotlib.pyplot`
6878

6979
Examples:
7080

7181
- :ref:`pyplot_tutorial`
7282
- :ref:`Pyplot examples <pyplots_examples>`
7383

7484

75-
The Axes interface
76-
^^^^^^^^^^^^^^^^^^
77-
78-
Typically, you will use `.pyplot.subplots` to create a `.Figure` and one or more
79-
`~matplotlib.axes.Axes` objects. From then on, you will use methods on these objects
80-
to add data, configure limits, set labels etc.
81-
82-
Relevant API:
83-
84-
85-
Examples:
86-
87-
88-
89-
The pyplot interface
90-
^^^^^^^^^^^^^^^^^^^^
91-
92-
`matplotlib.pyplot` is function based interface.a collection of functions that make
93-
Matplotlib work like MATLAB. Each pyplot function makes some change to a
94-
figure: e.g., creates a figure, creates a plotting area in a figure, plots
95-
some lines in a plotting area, decorates the plot with labels, etc.
96-
97-
`.pyplot` is mainly intended for interactive plots and simple cases of
98-
programmatic plot generation.
99-
100-
Further reading:
101-
102-
10385
.. _api-index:
10486

10587
Modules

lib/matplotlib/pylab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
`pylab` is a historic interface and its use is strongly discouraged. The equivalent
3-
replacement is `matplotlib.pyplot`. See :ref:` api_interfaces` for a full overview
3+
replacement is `matplotlib.pyplot`. See :ref:`api_interfaces` for a full overview
44
of Matplotlib interfaces.
55
66
`pylab` was designed to support a MATLAB-like way of working with all plotting related
@@ -14,7 +14,7 @@
1414
`numpy.fft`, `numpy.linalg`, and `numpy.random`, and some additional functions into
1515
the global namespace.
1616
17-
Such a pattern is nowadays considered bad practice, as it clutters the global
17+
Such a pattern is considered bad practice in modern python, as it clutters the global
1818
namespace. Even more severely, in the case of `pylab`, this will overwrite some
1919
builtin functions (e.g. the builtin `sum` will be replaced by `numpy.sum`), which
2020
can lead to unexpected behavior.

0 commit comments

Comments
 (0)