Matplotlib does not display hatching when rendering to pdf

Looks like a bug. Please file it in the github issue tracker.

In the meantime, here's a workaround:

plt.fill(x,np.sin(x),color='blue',alpha=0.5)
plt.fill(x,np.sin(x),color='None',alpha=0.5,edgecolor='blue',hatch='/')

TL;DR: use alpha=.99 to render hatches when exporting in PDF

It's nearly 2020 and the bug still exists when using plt.bar(). When rendering in PNG, everything is rendered properly. However, PDF export has a glitch when rendering hatches. Hatches are not visible, sometimes visible when zooming-in/out (sometimes not when tested on different computers), it is not clear where the bug comes from.

We realized it's linked with the alpha option. When using alpha=.5, the color is 50% visible, as well as hatches (50% visible as well). Good step, we have almost visible hatches. Therefore, let's just try with alpha=.99 so that everything is nearly 100% visible.

It works! Houray!

In our workaround, no need to duplicate lines like in previous answer. Keep the color option as it is and just set alpha=.99.