Adding polygons and shapes to our plots

We will begin by importing what we need to from Matplotlib, as shown here:

import numpy as npimport matplotlib as mplimport matplotlib.pyplot as plt%matplotlib inline# Set up figure size and DPI for screen demoplt.rcParams['figure.figsize'] = (6,4)plt.rcParams['figure.dpi'] = 150nums = np.arange(0,10,0.1)plt.plot(nums, np.sin(nums))

We will use the same sign plot as in the earlier section, Adding text to both axis and figure objects. As shown in the following output, this is the most basic sine plot and no annotations have been added yet:

Begin by adding a circle in-between them. Define the circle using ...

Get Mastering Matplotlib 2.x 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.