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

Skip to content

Commit 03d16a4

Browse files
committed
[DOC] Enhance API reference index
1 parent 80fb37d commit 03d16a4

File tree

2 files changed

+52
-14
lines changed

2 files changed

+52
-14
lines changed

doc/_static/mpl.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ table.property-table td {
122122
margin: 0 0.5em;
123123
}
124124

125+
/* Make the code examples in the API reference index the same height. */
126+
.api-interface-example pre {
127+
min-height: 6.5rem;
128+
}
129+
125130
/* Make inheritance images have a scroll bar if necessary. */
126131
div.graphviz {
127132
border: 1px solid lightgrey;

doc/api/index.rst

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,74 @@ API Reference
44
Matplotlib interfaces
55
---------------------
66

7-
Matplotlib provides two different interfaces:
8-
9-
- **Axes interface**: create a `.Figure` and one or more `~.axes.Axes` objects
10-
(typically using `.pyplot.subplots`), then *explicitly* use methods on these objects
11-
to add data, configure limits, set labels etc.
12-
- **pyplot interface**: consists of functions in the `.pyplot` module. Figure and Axes
13-
are manipulated through these functions and are only *implicitly* present in the
14-
background.
15-
16-
See :ref:`api_interfaces` for a more detailed description of both and their recommended
17-
use cases.
7+
.. |nbsp| unicode:: 0xA0
8+
:trim:
189

1910
.. grid:: 1 1 2 2
20-
:padding: 0 0 1 1
11+
:padding: 0
12+
:gutter: 2
2113

2214
.. grid-item-card::
15+
:class-footer: api-interface-footer
2316

2417
**Axes interface** (object-based, explicit)
25-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
create a `.Figure` and one or more `~.axes.Axes` objects, then *explicitly* use
20+
methods on these objects to add data, configure limits, set labels etc.
21+
22+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2623

2724
API:
2825

2926
- `~.pyplot.subplots`: create Figure and Axes
3027
- :mod:`~matplotlib.axes`: add data, limits, labels etc.
3128
- `.Figure`: for figure-level methods
3229

30+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31+
32+
Example:
33+
34+
.. code-block:: python
35+
:class: api-interface-example
36+
37+
fig, ax = plt.subplots()
38+
ax.plot(x, y)
39+
ax.set_title("Sample plot")
40+
plt.show()
41+
42+
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
43+
3344
.. grid-item-card::
45+
:class-footer: api-interface-footer
3446

3547
**pyplot interface** (function-based, implicit)
36-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48+
49+
consists of functions in the `.pyplot` module. Figure and Axes are manipulated
50+
through these functions and are only *implicitly* present in the background.
51+
52+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3753

3854
API:
3955

4056
- `matplotlib.pyplot`
4157

58+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59+
60+
Example:
61+
62+
.. code-block:: python
63+
:class: api-interface-example
64+
65+
plt.plot(x, y)
66+
plt.title("Sample plot")
67+
plt.show()
68+
69+
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
70+
71+
72+
See :ref:`api_interfaces` for a more detailed description of both and their recommended
73+
use cases.
74+
4275

4376
.. _api-index:
4477

0 commit comments

Comments
 (0)