- To get started with matplotlib using the object-oriented approach, you will need to import the pyplot module and alias plt:
>>> import matplotlib.pyplot as plt
- Typically, when using the object-oriented approach, we will create a Figure and one or more Axes objects. Let's use the subplots function to create a Figure with a single Axes:
>>> fig, ax = plt.subplots(nrows=1, ncols=1)
- The subplots function returns a two-item tuple object containing the Figure and one or more Axes objects (here it is just one), which is unpacked into the variables fig and ax. From here on out, we will directly use these objects by calling methods ...