Object-oriented interface
We will now look into what object-oriented interface matplotlib
is. We will discuss the following topics:
- The object-oriented interface
- Creating figures with a grid of subplots
- Plotting using methods
In the object-oriented interface, what we need to do is create the object and call methods for every object in order to make changes specifically to that object. Let's look at a simple example, where a plot is created using the object-oriented interface. We usually use the plt.subplots
function to create two objects at the same time. When we create a figure object, we usually call it fig
, and an axis object is usually called an ax
. In this case, the default function would be to produce a figure with one axis object, or one subplot. As we create our objects, some changes are involved. In order to make changes to our objects, namely, the plot, the title, or to set the labels, we use methods on these objects. Let's go through a few examples, with the diagrams as our point...