Skip to content

Commit 88863e1

Browse files
timhoffmjklymak
andcommitted
[DOC] Enhance API reference index
Co-authored-by: Jody Klymak <jklymak@gmail.com>
1 parent 80fb37d commit 88863e1

File tree

2 files changed

+47
-14
lines changed

2 files changed

+47
-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: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,69 @@ 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+
Matplotlib has two interfaces. See :ref:`api_interfaces` for a more detailed
8+
description of both and their recommended use cases.
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+
:shadow: none
16+
:class-footer: api-interface-footer
2317

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

2725
API:
2826

2927
- `~.pyplot.subplots`: create Figure and Axes
3028
- :mod:`~matplotlib.axes`: add data, limits, labels etc.
3129
- `.Figure`: for figure-level methods
3230

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

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

3855
API:
3956

4057
- `matplotlib.pyplot`
4158

59+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60+
61+
Example:
62+
63+
.. code-block:: python
64+
:class: api-interface-example
65+
66+
plt.plot(x, y)
67+
plt.title("Sample plot")
68+
plt.show()
69+
4270
4371
.. _api-index:
4472

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy