gpt4 book ai didi

python - Matplotlib:带阴影线的 PDF 图形分辨率低

转载 作者:太空宇宙 更新时间:2023-11-03 14:27:21 24 4
gpt4 key购买 nike

当使用 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 数据 Generated with EPS terminal

放大 PDF 图 Generated with PDF terminal

至于系统的具体细节,我使用的是 Ubuntu 13.04、Python 2.7.4 和 MPL 1.2.1。我尝试了不同的后端,但似乎无法解决这个问题。理想情况下,我希望在 EPS 和 PDF 中有漂亮的矢量图像,以便它对期刊友好。任何指针将不胜感激。

最佳答案

只是 Evince PDF 查看器的问题。在 Adob​​e Reader 中查看或打印绘图可获得所需的结果。

关于python - Matplotlib:带阴影线的 PDF 图形分辨率低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18060972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com