Matplotlib fill_between() does not save correctly

2019-04-10 23:23发布

I am running into the following issue when trying to save a matplotlib fill_between() plot as a pdf in ipython.

import matplotlib.pyplot as plt
A =[1,2,3,4,5,6]
B = [10,20,30,40,50,60]
plt.fill_between(A,A,B,color="none", hatch="\\\\\\\\\\\\", edgecolor="grey", linewidth=0.0,alpha=1)
plt.savefig('test.pdf')

when I run this, I find the following plot in the ipython notebook: image shown in the ipython notebook, or when saved directly as .png

However, when I open the saved file, it instead looks like this: image when saved as a pdf

The hatches are barely visible. I need a high-quality plot, which is why I am trying to save as a pdf instead of as a png, for example. Is there a way to increase the linewidth of the hatches when saving the pdf?

0条回答
登录 后发表回答