I do not like those layers
pylab
: massive namespace dump that pulls in everything frompyplot
andnumpy
. It is not a 'layer' so much as a very cluttered name space.pyplot
: state-machine based layer (it knows what your 'current axes' and 'current figure' are and applies the functions to that axes/figure. You should use this only when you are playing around in an interactive terminal (other thanplt.subplots
orplt.figure
for setting up the figure/axes objects). Making a distiction between this layer andpylab
is dumb. This is the layer that makes it 'like MATLAB'- the OO layer : which is what you should use in all of your scripts
Figure
s are the top level container objects. They can contain Axes
objects and Artist
objects (technically Axes
are Artists
, but it is useful for pedagogical reasons to distinguish between the Axes
objects in a figure and the other artists (such as text
objects) that are in the Figure
, but not associated with an Axes
) and know about the Canvas
object. Each Axes
can contain more Artists
objects. The Artists
are the useful things you want to put on your graph (lines, text, images, etc). Artists
know how to draw themselves on a Canvas
. When you call fig.savefig
(or render the figure to the screen) the Figure
object loops over all of it's children and tell them to draw them selves on to it's Canvas
.
The different Backends
provide implementations of the Canvas
objects, hence the same figure can be rendered to a raster or vector graphic by just changing the Canvas
object that is being used.
Unless you want to write a new backend, many of these details are not important and the fact that matplotlib hides them from you is why it is useful.
If the book couldn't get this correct, I would take everything it says with grain of salt.