Matplotlib does not display hatching when rendering to pdf

I am attempting to use the hatching feature in matplotlib, which works fine when displaying to screen. However when I save the figure to pdf format, the hatch marks are not rendered:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0,2*np.pi,100)

plt.figure()
plt.fill(x,np.sin(x),color='blue',alpha=0.5,hatch='/')
plt.show()
plt.savefig('./test.pdf',format='pdf')

I am using matplotlib 1.0.1 in pylab on OS X 10.6.6. This may be a platform specific issue having to do with the backend renderer, but I'm not sure. Any suggestions would be most appreciated.


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='/')
链接地址: http://www.djcxy.com/p/51190.html

上一篇: PHP:scandir()太慢了

下一篇: 在渲染为pdf时,Matplotlib不显示阴影