当使用Matplotlib生成带有图案填充的图形(例如饼图、条形图、气泡图)时,我很难从PDF版本的图形中获得像样的分辨率。保存为EPS是可以的,但是只要我使用epstopdf
或MPL的savefig(*.pdf)
,图案填充就会变得像素化和离散化。。。图像的矢量特性似乎已经丢失。在
请参阅下面的最小代码。在
from matplotlib import pyplot as plt
# Define hatching styles
hatching = ["/", "o"]
fig, ax = plt.subplots()
wedges, texts = ax.pie([0.4, 0.6], colors=("SteelBlue", "Tomato"))
# Apply the hatching
for j, patch in enumerate(wedges): patch.set_hatch(hatching[j])
fig.savefig("hatchtest.pdf")
我用Gimp放大了一部分情节来说明区别。。。在
放大EPS图
放大PDF图
至于具体的系统细节,我使用的是Ubuntu13.04、Python2.7.4和MPL1.2.1。我尝试过不同的后端,但似乎没有解决这个问题。我最理想的是在EPS和PDF中有很好的矢量图像,这样它对日志都很友好。任何建议都将不胜感激。在
只是Evince PDF查看器有问题。在AdobeReader中查看或打印绘图会得到所需的结果。在
相关问题 更多 >
编程相关推荐