Pyplot is the high-level, MATLAB-style interface to Matplotlib. It’s the submodule conventionally imported as plt:
import matplotlib.pyplot as pltPyplot provides functions like plt.plot(x, y), plt.scatter(x, y), plt.title(...), plt.show() that work on an implicit current figure and axes. You don’t have to create the figure or axes objects yourself — Pyplot maintains them in the background and applies your commands to whichever one is current. This is convenient for quick scripts and interactive exploration.
The downside of the implicit-current-figure model is that it breaks down as soon as you want explicit control over multiple plots, or you want to build a figure from a function that doesn’t know about the current state. For that, the object-oriented style is preferred — explicitly create a figure and axes and call methods on them:
fig, ax = plt.subplots() # explicit figure + axes
ax.plot(x, y)
ax.set_title('My plot')
plt.show()The convention in production code and library code is the object-oriented style. The Pyplot one-liner style is fine for notebook exploration and very small scripts.
Pyplot is one submodule of Matplotlib’s larger ecosystem. The core types — Figure and Axes — are defined elsewhere; Pyplot is mostly a convenience layer that creates them on demand and dispatches function calls to them.