The pyplot API code block is self-explanatory. Here is the output chart:
Here is the explanation for the object-oriented API code block:
- Figure(figsize=(12,9)) instantiates the figure object with a size of (12, 9).
- FigureCanvas(fig) attaches the canvas (area where the figure needs to be plotted, which ultimately gets displayed on the connected backend device). In the case of the pyplot API, we don't have to do this, as the pyplot API takes care of it.
- fig.add_subplot(111) creates the axis object within the figure object created earlier. Please note we can create multiple axes objects within one figure object. Here, we are ...