pyplot
is the ‘scripting’ level API in matplotlib (its highest level API to do a lot with matplotlib). It allows you to use matplotlib using a procedural interface in a similar way as you can do it with Matlab. pyplot
has a notion of ‘current figure’ and ‘current axes’ that all the functions delegate to (@tacaswell dixit). So, when you use the functions available on the module pyplot
you are plotting to the ‘current figure’ and ‘current axes’.
If you want ‘fine-grain’ control of where/what your are plotting then you should use an object oriented API using instances of Figure
and Axes
.
Functions available in pyplot
have an equivalent method in the Axes
.
From the repo anatomy of matplotlib:
- The
Figure
is the top-level container in this hierarchy. It is the overall window/page that everything is drawn on. You can have multiple independent figures andFigure
s can contain multiple Axes.
But…
-
Most plotting occurs on an
Axes
. The axes is effectively the area that we plot data on and any ticks/labels/etc associated with it. Usually we’ll set up anAxes
with a call to subplot (which placesAxes
on a regular grid), so in most cases,Axes
andSubplot
are synonymous. -
Each
Axes
has an XAxis and a YAxis. These contain the ticks, tick locations, labels, etc.
If you want to know the anatomy of a plot you can visit this link.