首页 > 解决方案 > 将eps图像转换为pdf时如何避免灰色轮廓伪影?

问题描述

为了生成带有 LaTeX 标签的矢量图形,我使用 gnuplot 和 cairolatex 终端,通过以下方式创建图像plot "data.txt" u 1:2:3 matrix with image notitle

latex figuregen.tex
dvips -E -ofile.eps figuregen

# Correct the bounding box automatically:
epstool --copy --bbox file.eps filename.eps

## Create a pdf:
ps2pdf -dPDFSETTINGS=/prepress -dSubsetFonts=true -dEmbedAllFonts=true -dMaxSubsetPct=100 -dCompatibilityLevel=1.3 -dEPSCrop filename.eps filename.pdf

这是原始 eps 图像的特定区域的放大图: eps文件 白色区域实际上对应于数据文件中的 NaN 值。

现在使用从 eps 转换的 pdf 文件: 在 pdf 版本中,现在所有 NaN 像素周围都有不需要的轮廓,在图像的较高部分产生了大量的噪点转换为pdf后

我想将这些图像作为 pdf 格式,没有人工制品,并保留高质量的 LaTeX 标签。我怀疑可能有一个ps2pdf选项可以停用这种不需要的行为,但我就是找不到它。

我尝试了诸如:-dGraphicsAlphaBits=1, -dNOINTERPOLATE, -dALLOWPSTRANSPARENCY, -dNOTRANSPARENCY, -dCompatibilityLevel=1.4or之类的东西-dCompatibilityLevel=1.5,但没有成功。

我也尝试直接在 中修复此问题gnuplot,但没有成功(参见下面的示例)。

你们中有人知道如何解决这个问题吗?

非常感谢您的宝贵时间!

编辑

更令人惊讶和有问题的是,这些人工制品在打印时也会出现

但是请注意,当仅绘制数据集的一小部分时,它们不会出现在极端的放大水平上。

MWE:

# plot.plt
set size ratio -1

set palette defined ( 0 '#D73027', 1 '#F46D43', 2 '#FDAE61', 3 '#FEE090', 4 '#FFFFD9', 5 '#E0F3F8', 6 '#ABD9E9', 7 '#74ADD1', 8 '#4575B4' )

#set yr [300:0] ### no artefacts if zoom is higher than 1310% in evince
set yr [400:100] ### no artefacts if zoom is higher than 1780% in evince
#set yr [450:0] ### artefacts at all zoom levels if we show more data, or all of it

set term cairolatex dashed color; set output "temp.tex"

plot "data.txt" u 1:2:3 matrix with image notitle

set output #Closes the temporary output file.   
!sed -e 's|/Title|%/Title|' -e 's|/Subject|%/Subject|' -e 's|/Creator|%/Creator|' -e 's|/Author|%/Author|' < temp.tex > graph.tex

并且,为了完整起见:

% figuregen.tex

\documentclass[dvips]{article}
\pagestyle{empty}
\usepackage[dvips]{graphicx} %
\begin{document}
\input graph.tex   
\end{document}

如果需要,可以在此处以文本形式找到部分数据;足以重现该问题:https ://paste.nomagic.uk/?e0343cc8f759040a#DkRxNiNrH6d3QMZ985CxhA21pG2HpVEShrfjg84uvAdt

编辑 2

实际上,使用时会出现相同的伪影问题set terminal cairolatex pdf

set terminal cairolatex standalone pdf size 16cm,10.5cm dashed transparent
set output "plot.tex"

直接用pdflatex

gnuplot<plot.plt
pdflatex plot.tex

(注意,这是使用 Gnuplot 版本 5.2 补丁级别 6)。

标签: pdfgnuplotfile-conversioneps

解决方案


只是为了记录,with image pixels似乎做了“伎俩”,并将创建一个没有灰色数据点周围的文件NaN。使用 gnuplot 5.2.6 测试。

 plot FILE u 1:2:3 matrix with image pixels notitle

代码:

### avoid shading around NaN datapoints
reset session

set size ratio -1
FILE = "data.txt"

set palette defined ( 0 '#D73027', 1 '#F46D43', 2 '#FDAE61', 3 '#FEE090', 4 '#FFFFD9', 5 '#E0F3F8', 6 '#ABD9E9', 7 '#74ADD1', 8 '#4575B4' )

set term cairolatex dashed color
set output "temp.tex"

plot FILE u 1:2:3 matrix with image pixels notitle

set output
### end of code

结果:(截图的PNG,因为看起来我无法在此处添加PDF)

在此处输入图像描述


推荐阅读