【问题标题】:How to remove unknown slits when using filledcurve in Gnuplot (epslatex)?在 Gnuplot(epslatex)中使用填充曲线时如何删除未知的狭缝?
【发布时间】:2014-04-06 04:41:01
【问题描述】:

我现在尝试在 gnuplot 4.6 补丁级别 1 中使用 filledcurve。下面显示了示例脚本:

set term epslatex
set output "figure.tex"

set xlabel "\\huge{x-axis}"
set ylabel "\\huge{y-axis}"
set format xy "\\LARGE{%.0f}"
set xrange [0.0:10.0]
set yrange [0.0:100.0]
set xtics 2.0
set ytics 20.0
set xtics offset 0, -0.3

f1(x) = x**1
f2(x) = x**2
f3(x) = x**3

set nokey
plot '+' using 1:(f2($1)):(f3($1)) with filledcurve lt 1 lc rgb "gray60",\
     '+' using 1:(f1($1)):(f2($1)) with filledcurve lt 1 lc rgb "gray40",\
     '+' using 1:(0.0):(f1($1))    with filledcurve lt 1 lc rgb "gray20"

我不知道为什么,但是酒吧之间似乎有白色恼人的缝隙。即使我增加set samples的数量也无法摆脱。

有什么办法可以去掉这些缝隙吗?

【问题讨论】:

  • 我也注意到了这一点,但这似乎是与显示图形有关的问题,而不是 gnuplot 问题。也许这个显示问题是由 gnuplot 如何生成图形触发的,我不知道。例如,如果您使用 GIMP 导入 eps 文件,白线将消失。另外,打印时也没有效果。
  • 谢谢,@Miguel。我还检查了使用“evince”(这是一个用于显示 eps 数字的 linux 命令)以及打印时这些行不存在。但是,如果我将 eps 图形放入 Latex 文件中,则会再次出现这些行。
  • 当我使用 latex 和您的脚本构建 dvi 文件时,这些行消失了,然后在使用 dvipdf 导出为 PDF 时又回来了。也许如果您对传递给dvipdf 的选项稍加摆弄,您可以防止这种情况发生(我不知道),或者使用一些不同的实用程序,例如dvipdfmx 左右。有机会我会尝试看看,因为我自己对此很感兴趣。
  • 查看错误报告sourceforge.net/p/gnuplot/bugs/1259 进行相关讨论。

标签: latex gnuplot eps


【解决方案1】:

不幸的是,这是与绘制相邻填充多边形相关的查看器问题,另请参阅problematic Moire pattern in image produced with gnuplot pm3d and pdf output 或错误报告#1259 cairolatex pdf fill patterns

在您的情况下,您可以使用解决方法:

using 语句中只有两列时,该区域将绘制为闭合多边形并且不显示这些伪影 (filledcurves closed)。所以你必须填充每条曲线和x1 轴之间的区域(使用filledcurves x1)。

由于剪裁超出 y 范围的曲线存在错误,您必须自己剪裁f3 曲线(即使用f3($1) > 100 ? 100 : f3($1))。此错误已在开发版中修复。

所以你的脚本是:

set term epslatex standalone
set output "figure.tex"

set xlabel "\\huge x-axis"
set ylabel "\\huge y-axis"
set format xy "\\LARGE %.0f"
set xrange [0.0:10.0]
set yrange [0.0:100.0]
set xtics 2.0
set ytics 20.0
set xtics offset 0, -0.3

f1(x) = x**1
f2(x) = x**2
f3(x) = x**3

set nokey
plot '+' using 1:(f3($1) > 100 ? 100 : f3($1)) with filledcurve x1 lt 1 lc rgb "gray60",\
     '+' using 1:(f2($1)) with filledcurve x1 lt 1 lc rgb "gray40",\
     '+' using 1:(f1($1)) with filledcurve x1 lt 1 lc rgb "gray20"

set output
system('latex figure.tex && dvips figure.dvi && ps2pdf figure.ps')

结果(使用 4.6.1):

还要注意,像 \huge 这样的 LaTeX 命令不带参数,而是开关。测试例如\huge{A}BC,这将使所有字母变得巨大。通常你必须用{\huge ABC}这样的括号来限制\huge的范围,但是如果整个标签都受到影响,使用set xlabel "\\huge x-axis"就足够了。这不会改变你的情况,但在其他情况下可能会给你带来麻烦:)

【讨论】:

  • 谢谢,@Christoph!它有效,对我来说是完美的解决方案。
  • 另外,感谢您对 LaTeX 命令的建议。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多