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

Skip to content

Commit 1937d0b

Browse files
authored
Merge pull request #19727 from jklymak/doc-api-frontpage
DOC: simplify API index
2 parents 12b7c29 + 783f606 commit 1937d0b

File tree

2 files changed

+78
-47
lines changed

2 files changed

+78
-47
lines changed

doc/_templates/layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<ul>
5757
<li><a href="{{ pathto('users/installing') }}">Installation</a></li>
5858
<li><a href="{{ pathto('contents') }}">Documentation</a></li>
59+
<li><a href="{{ pathto('api/index') }}">API</a></li>
5960
<li><a href="{{ pathto('gallery/index') }}">Examples</a></li>
6061
<li><a href="{{ pathto('tutorials/index') }}">Tutorials</a></li>
6162
<li><a href="{{ pathto('devel/index') }}">Contributing</a></li>

doc/api/index.rst

Lines changed: 77 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,46 @@
1-
API Overview
2-
============
1+
API
2+
===
33

44
.. toctree::
55
:hidden:
66

77
api_changes
88

9-
.. contents:: :local:
9+
For recent changes, see :doc:`api_changes`.
1010

11-
See also the :doc:`api_changes`.
11+
When using the library you will typically create
12+
:doc:`Figure <figure_api>` and :doc:`Axes <axes_api>` objects and
13+
call their methods to add content and modify the apprearance.
1214

13-
Usage patterns
14-
--------------
15-
16-
Below we describe several common approaches to plotting with Matplotlib.
17-
18-
The pyplot API
19-
^^^^^^^^^^^^^^
20-
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.
15+
- :doc:`figure_api`: axes creation, figure-level content
16+
- :doc:`axes_api`: most plotting methods, Axes labels, access to
17+
axis styling, etc.
2518

26-
`.pyplot` is mainly intended for interactive plots and simple cases of
27-
programmatic plot generation.
19+
Example: We create a Figure ``fig`` and Axes ``ax``. Then we call
20+
methods on them to plot data, add axis labels and a figure title.
21+
22+
.. plot::
23+
:include-source:
24+
:align: center
2825

29-
Further reading:
26+
import matplotlib.pyplot as plt
27+
import numpy as np
3028

31-
- The `matplotlib.pyplot` function reference
32-
- :doc:`/tutorials/introductory/pyplot`
33-
- :ref:`Pyplot examples <pyplots_examples>`
29+
x = np.arange(0, 4, 0.05)
30+
y = np.sin(x*np.pi)
3431

35-
.. _api-index:
32+
fig, ax = plt.subplots(figsize=(3,2), constrained_layout=True)
33+
ax.plot(x, y)
34+
ax.set_xlabel('t [s]')
35+
ax.set_ylabel('S [V]')
36+
ax.set_title('Sine wave')
37+
fig.set_facecolor('lightsteelblue')
3638

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:
6039

6140
Modules
6241
-------
6342

64-
Matplotlib consists of the following submodules:
43+
Alphabetical list of modules:
6544

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

0 commit comments

Comments
 (0)