Axes.fill_between() for two arbitrary curves


I have two arrays of coordinates in the x-y plane, z_1 and z_2. The array z_1 encloses a closed, convex and simply connected region (not a circle). The array z_2 encloses another object that is also closed, convex and simply connected. The region enclosed by z_2 is contained entirely within the region described by z_1. The picture in your head should be of one blob inside another.

I want to use Axes.fill_between() to fill the ‘annulus’ region. This is the region containing points that are enclosed by z_1, but not by z_2. Is this possible? I’ve tried fiddling with the ‘where’ kwarg to no avail. Since they are not circles, I figured this is a no-go with the current matplotlib Axes.* functions. Is my best bet to build a PolyCollection or a matplotlib.patch and add it to the axes myself?

Any help is greatly appreciated.

Thank you.


Damon McDougall



Mathematics Institute

University of Warwick


West Midlands


United Kingdom