Last updated
Last updated
For all Matplotlib plots, we start by creating a figure and axes. In their simplest form, a figure and axes can be created as follows:
For better understanding axes, here is an example, we can plot several axes in one figure
According to the last chapter, could you find the flaw of the chart?
As noted above, there are essentially two ways to use Matplotlib:
Explicitly create figures and axes, and call methods on them (the "object-oriented (OO) style").
Rely on pyplot
to automatically create and manage the figures and axes, and use pyplot
functions for plotting.
Matplotlib graphs your data on s (i.e., windows, Jupyter widgets, etc.), each of which can contain one or more (i.e., an area where points can be specified in terms of x-y coordinates. It's called object-oriented. In other words, you need to create objects.
There is a corresponding function in the module that performs that plot on the "current" axes, creating that axes (and its parent figure) if they don't exist. So the previous example can be written more shortly as
If you forget the elements of plot, find it