matplotlib.pyplot is a collection of functions that make matplotlibwork like MATLAB. Each pyplot function makes some change to a figure:e.g., creates a figure, creates a plotting area in a figure, plots some linesin a plotting area, decorates the plot with labels, etc.
In matplotlib.pyplot various states are preservedacross function calls, so that it keeps track of things likethe current figure and plotting area, and the plottingfunctions are directed to the current axes (please note that "axes" hereand in most places in the documentation refers to the axespart of a figureand not the strict mathematical term for more than one axis).
The pyplot API consists of a hierarchy of Python code objects, and includes numerous functions topped by matplotlib.pyplot. This stack can be viewed as having three interdependent layers:
The top-level object in the scripting layer is matplotlib.pyplot.figure(), otherwise known as the Figure. The figure acts as a container that manages all of the elements in a given plot.