From 88863e1bc62a203d606d19d0aa3e14de12ceeeb6 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 31 Aug 2023 00:42:29 +0200 Subject: [PATCH] [DOC] Enhance API reference index Co-authored-by: Jody Klymak --- doc/_static/mpl.css | 5 ++++ doc/api/index.rst | 56 +++++++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/doc/_static/mpl.css b/doc/_static/mpl.css index e9d7d65f3e01..45ecb21d5511 100644 --- a/doc/_static/mpl.css +++ b/doc/_static/mpl.css @@ -122,6 +122,11 @@ table.property-table td { margin: 0 0.5em; } +/* Make the code examples in the API reference index the same height. */ +.api-interface-example pre { + min-height: 6.5rem; +} + /* Make inheritance images have a scroll bar if necessary. */ div.graphviz { border: 1px solid lightgrey; diff --git a/doc/api/index.rst b/doc/api/index.rst index 1b098009faed..e55a0ed3c5b2 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -4,25 +4,23 @@ API Reference Matplotlib interfaces --------------------- -Matplotlib provides two different interfaces: - -- **Axes interface**: create a `.Figure` and one or more `~.axes.Axes` objects - (typically using `.pyplot.subplots`), then *explicitly* use methods on these objects - to add data, configure limits, set labels etc. -- **pyplot interface**: consists of functions in the `.pyplot` module. Figure and Axes - are manipulated through these functions and are only *implicitly* present in the - background. - -See :ref:`api_interfaces` for a more detailed description of both and their recommended -use cases. +Matplotlib has two interfaces. See :ref:`api_interfaces` for a more detailed +description of both and their recommended use cases. .. grid:: 1 1 2 2 - :padding: 0 0 1 1 + :padding: 0 + :gutter: 2 .. grid-item-card:: + :shadow: none + :class-footer: api-interface-footer **Axes interface** (object-based, explicit) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + create a `.Figure` and one or more `~.axes.Axes` objects, then *explicitly* use + methods on these objects to add data, configure limits, set labels etc. + + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ API: @@ -30,15 +28,45 @@ use cases. - :mod:`~matplotlib.axes`: add data, limits, labels etc. - `.Figure`: for figure-level methods + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + Example: + + .. code-block:: python + :class: api-interface-example + + fig, ax = plt.subplots() + ax.plot(x, y) + ax.set_title("Sample plot") + plt.show() + + .. grid-item-card:: + :shadow: none + :class-footer: api-interface-footer **pyplot interface** (function-based, implicit) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + consists of functions in the `.pyplot` module. Figure and Axes are manipulated + through these functions and are only *implicitly* present in the background. + + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ API: - `matplotlib.pyplot` + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + Example: + + .. code-block:: python + :class: api-interface-example + + plt.plot(x, y) + plt.title("Sample plot") + plt.show() + .. _api-index: 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