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

Skip to content

Commit 2716870

Browse files
committed
DOC: simplify API index
1 parent c2946de commit 2716870

File tree

3 files changed

+77
-52
lines changed

3 files changed

+77
-52
lines changed

doc/api/axes_api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _axes_api
2+
13
*******************
24
``matplotlib.axes``
35
*******************

doc/api/figure_api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _figure_api
2+
13
*********************
24
``matplotlib.figure``
35
*********************

doc/api/index.rst

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,39 @@
1-
API Overview
2-
============
1+
API
2+
===
33

4-
.. toctree::
5-
:hidden:
4+
For recent changes, see :doc:`api_changes`.
65

7-
api_changes
6+
Much of the library can be accessed by creating :doc:`Figure <figure_api>`
7+
and :doc:`Axes <axes_api>` objects and accessing methods on them.
88

9-
.. contents:: :local:
9+
- :doc:`figure_api`: axes creation, figure-level artists
10+
- :doc:`axes_api`: most plotting methods, axes labels, access to
11+
axis styling, etc.
1012

11-
See also the :doc:`api_changes`.
13+
Simple example: note how the ``ax`` object has the `.axes.Axes.plot` method
14+
that is used to create the line plot.
15+
16+
.. plot::
17+
:include-source:
18+
:align: center
1219

13-
Usage patterns
14-
--------------
20+
import matplotlib.pyplot as plt
21+
import numpy as np
1522

16-
Below we describe several common approaches to plotting with Matplotlib.
23+
x = np.arange(0, 4, 0.1)
24+
y = np.sin(x*np.pi)
1725

18-
The pyplot API
19-
^^^^^^^^^^^^^^
26+
fig, ax = plt.subplots(figsize=(3,2), constrained_layout=True)
27+
ax.plot(x, y)
28+
ax.set_xlabel('t [s]')
29+
ax.set_ylabel('S [V]')
30+
fig.suptitle('Sine wave')
2031

21-
`matplotlib.pyplot` is a collection of command style functions that make
22-
Matplotlib work like MATLAB. Each pyplot function makes some change to a
23-
figure: e.g., creates a figure, creates a plotting area in a figure, plots
24-
some lines in a plotting area, decorates the plot with labels, etc.
25-
26-
`.pyplot` is mainly intended for interactive plots and simple cases of
27-
programmatic plot generation.
28-
29-
Further reading:
30-
31-
- The `matplotlib.pyplot` function reference
32-
- :doc:`/tutorials/introductory/pyplot`
33-
- :ref:`Pyplot examples <pyplots_examples>`
34-
35-
.. _api-index:
36-
37-
The object-oriented API
38-
^^^^^^^^^^^^^^^^^^^^^^^
39-
40-
At its core, Matplotlib is object-oriented. We recommend directly working
41-
with the objects, if you need more control and customization of your plots.
42-
43-
In many cases you will create a `.Figure` and one or more
44-
`~matplotlib.axes.Axes` using `.pyplot.subplots` and from then on only work
45-
on these objects. However, it's also possible to create `.Figure`\ s
46-
explicitly (e.g. when including them in GUI applications).
47-
48-
Further reading:
49-
50-
- `matplotlib.axes.Axes` and `matplotlib.figure.Figure` for an overview of
51-
plotting functions.
52-
- Most of the :ref:`examples <examples-index>` use the object-oriented approach
53-
(except for the pyplot section)
54-
55-
The pylab API (disapproved)
56-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
57-
58-
.. automodule:: pylab
59-
:no-members:
6032

6133
Modules
6234
-------
6335

64-
Matplotlib consists of the following submodules:
36+
Alphabetical list of all submodules:
6537

6638
.. toctree::
6739
:maxdepth: 1
@@ -147,3 +119,52 @@ Matplotlib. The following toolkits are included:
147119
toolkits/axes_grid1.rst
148120
toolkits/axisartist.rst
149121
toolkits/axes_grid.rst
122+
123+
124+
Usage patterns
125+
--------------
126+
127+
Below we describe several common approaches to plotting with Matplotlib.
128+
129+
The pyplot API
130+
^^^^^^^^^^^^^^
131+
132+
`matplotlib.pyplot` is a collection of command style functions that make
133+
Matplotlib work like MATLAB. Each pyplot function makes some change to a
134+
figure: e.g., creates a figure, creates a plotting area in a figure, plots
135+
some lines in a plotting area, decorates the plot with labels, etc.
136+
137+
`.pyplot` is mainly intended for interactive plots and simple cases of
138+
programmatic plot generation.
139+
140+
Further reading:
141+
142+
- The `matplotlib.pyplot` function reference
143+
- :doc:`/tutorials/introductory/pyplot`
144+
- :ref:`Pyplot examples <pyplots_examples>`
145+
146+
.. _api-index:
147+
148+
The object-oriented API
149+
^^^^^^^^^^^^^^^^^^^^^^^
150+
151+
At its core, Matplotlib is object-oriented. We recommend directly working
152+
with the objects, if you need more control and customization of your plots.
153+
154+
In many cases you will create a `.Figure` and one or more
155+
`~matplotlib.axes.Axes` using `.pyplot.subplots` and from then on only work
156+
on these objects. However, it's also possible to create `.Figure`\ s
157+
explicitly (e.g. when including them in GUI applications).
158+
159+
Further reading:
160+
161+
- `matplotlib.axes.Axes` and `matplotlib.figure.Figure` for an overview of
162+
plotting functions.
163+
- Most of the :ref:`examples <examples-index>` use the object-oriented approach
164+
(except for the pyplot section)
165+
166+
The pylab API (disapproved)
167+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
168+
169+
.. automodule:: pylab
170+
:no-members:

0 commit comments

Comments
 (0)