Skip to content

Commit d49767e

Browse files
authored
Merge pull request #21093 from jklymak/doc-clarify-object-oriented
DOC: clarify what we mean by object oriented in pyplot api
2 parents 15ba811 + f77b426 commit d49767e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/matplotlib/pyplot.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
"""
55
`matplotlib.pyplot` is a state-based interface to matplotlib. It provides
6-
a MATLAB-like way of plotting.
6+
an implicit, MATLAB-like, way of plotting. It also opens figures on your
7+
screen, and acts as the figure GUI manager.
78
89
pyplot is mainly intended for interactive plots and simple cases of
910
programmatic plot generation::
@@ -15,7 +16,19 @@
1516
y = np.sin(x)
1617
plt.plot(x, y)
1718
18-
The object-oriented API is recommended for more complex plots.
19+
The explicit (object-oriented) API is recommended for complex plots, though
20+
pyplot is still usually used to create the figure and often the axes in the
21+
figure. See `.pyplot.figure`, `.pyplot.subplots`, and
22+
`.pyplot.subplot_mosaic` to create figures, and
23+
:doc:`Axes API <../axes_api>` for the plotting methods on an axes::
24+
25+
import numpy as np
26+
import matplotlib.pyplot as plt
27+
28+
x = np.arange(0, 5, 0.1)
29+
y = np.sin(x)
30+
fig, ax = plt.subplots()
31+
ax.plot(x, y)
1932
"""
2033

2134
import functools

0 commit comments

Comments
 (0)