From 979fe946a7673f3559ef3c058179f1bfad337927 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Thu, 16 Sep 2021 13:16:53 +0200 Subject: [PATCH] DOC: clarify what we mean by object oriented Co-authored-by: Thomas A Caswell --- lib/matplotlib/pyplot.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index b222466dda45..e80e16c4b0b2 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -3,7 +3,8 @@ """ `matplotlib.pyplot` is a state-based interface to matplotlib. It provides -a MATLAB-like way of plotting. +an implicit, MATLAB-like, way of plotting. It also opens figures on your +screen, and acts as the figure GUI manager. pyplot is mainly intended for interactive plots and simple cases of programmatic plot generation:: @@ -15,7 +16,19 @@ y = np.sin(x) plt.plot(x, y) -The object-oriented API is recommended for more complex plots. +The explicit (object-oriented) API is recommended for complex plots, though +pyplot is still usually used to create the figure and often the axes in the +figure. See `.pyplot.figure`, `.pyplot.subplots`, and +`.pyplot.subplot_mosaic` to create figures, and +:doc:`Axes API <../axes_api>` for the plotting methods on an axes:: + + import numpy as np + import matplotlib.pyplot as plt + + x = np.arange(0, 5, 0.1) + y = np.sin(x) + fig, ax = plt.subplots() + ax.plot(x, y) """ import functools