Matplotlib is capable of drawing polygons with a hatched pattern, such as the one below, using the patch function. The key is in the “hatch=” parameter, in this case it is ‘/’ to add diagonal lines. According to the documentation it can also be one of these:

/ \ | - + x o O . *

Add a rectangle patch like this:

ax.add_patch(Polygon([[.2,.5],[.2,.75],[.8,.75],[.8, .5]], hatch='/', color='blue', lw=0, fill=False))

But what if you want a more dense hatch pattern? I stumbled across the answer, and it’s quite simple, just increase the characters in the hatch parameter. For example, use hatch=’//’ instead of a single hatch=’/’.

ax.add_patch(Polygon([[.2,.5],[.2,.75],[.8,.75],[.8, .5]], hatch='/', color='blue', lw=0, fill=False))
ax.add_patch(Polygon([[.2,.1],[.2,.35],[.45,.35],[.45, .1]], hatch='//', color='blue', lw=0, fill=False))
ax.add_patch(Polygon([[.55,.1],[.55,.35],[.8,.35],[.8, .1]], hatch='///', color='blue', lw=0, fill=False))

It also works with the other patterns, like hatch=’…’.

And you can combine different types, to make hatches that make you dizzy, such as hatch=’+/’.