Filling an under-plot area
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 we will learn how to shade certain areas of plot intersections.
Getting ready
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.pyploy.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 function fill_between
accepts argument x
—an x axis...