From c14056d59f3c20140ca44aaf3f0611c096121769 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 29 Aug 2023 10:53:44 -0700 Subject: [PATCH] DOC: re-add api example --- doc/api/index.rst | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/doc/api/index.rst b/doc/api/index.rst index 1b098009faed..f1ca56d0c851 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -24,10 +24,8 @@ use cases. **Axes interface** (object-based, explicit) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - API: - - - `~.pyplot.subplots`: create Figure and Axes - - :mod:`~matplotlib.axes`: add data, limits, labels etc. + - `~.pyplot.subplots` or `~.pyplot.subplot_mosaic`: create Figure and Axes + - `Axes `: add data, limits, labels etc. - `.Figure`: for figure-level methods .. grid-item-card:: @@ -35,10 +33,47 @@ use cases. **pyplot interface** (function-based, implicit) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - API: - - `matplotlib.pyplot` +.. tab-set:: + + .. tab-item:: Axes interface + + .. plot:: + :include-source: + :align: center + + x = np.arange(0, 4, 0.05) + y = np.sin(x*np.pi) + # Create a Figure and an Axes: + fig, ax = plt.subplots(figsize=(3,2), layout='constrained') + # Use the Axes to plot and label: + ax.plot(x, y) + ax.set_xlabel('t [s]') + ax.set_ylabel('S [V]') + ax.set_title('Sine wave') + # Change a property of the Figure: + fig.set_facecolor('lightsteelblue') + + + .. tab-item:: pyplot interface + + .. plot:: + :include-source: + :align: center + + x = np.arange(0, 4, 0.05) + y = np.sin(x*np.pi) + # Create a Figure of a given size: + plt.figure(figsize=(3, 2), layout='constrained') + # plot on a default Axes on the Figure: + plt.plot(x, y) + plt.xlabel('t [s]') + plt.ylabel('S [V]') + plt.title('Sine wave') + # set a Figure property: + plt.gcf().set_facecolor('lightsteelblue') + .. _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