How to do it...

  1. 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
  1. 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)
  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 ...

Get Pandas Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.