The basic way to draw a filled polygon in matplotlib is to use matplotlib.pyplot.fill
. This function accepts similar arguments as matplotlib.pyplot.plot
—multiple x and y pairs and other Line2D properties. This function returns the list of patch instances that were added.
In this recipe, you will learn how to shade certain areas of plot intersections.
matplotlib provides several functions to help us plot filled figures, apart from plotting functions that are inherently plotting closed filled polygons, such as histogram ()
, of course.
We already mentioned one—matplotlib.pyplot.fill
—but there are the matplotlib.pyplot.fill_between()
and matplotlib.pyplot.fill_betweenx()
functions too. These functions fill the polygons between two curves. The main difference between fill_between()
and fill_betweenx()
is that the latter fills between the x axis values, whereas the former fills between the y axis values.
The fill_between
function accepts argument x
—an x axis...