gnuplot:cairolatex 背景问题

gnuplot: cairolatex background issues

我在 gnuplot 中遇到 cairolatex 终端问题。

我的终端设置如下:

et terminal cairolatex eps rounded size 5,3 font ',17' standalone background "#9e9e9e"

绘图外的背景设置正确,但绘图区域内仍为白色。我也试过用同样的问题“透明”。基本上,包含在latex中的自动生成的文件filename-inc是不正确的。

在所附图片中,您可以看到投影仪幻灯片的灰色背景,其中包含通过 cairolatex 使用 gnuplot 生成的 pdf。

这让我发疯。

编辑: 这是最少的代码。

#!/usr/local/bin/gnuplot

set terminal cairolatex eps rounded size 5,3 font ',17' standalone background "#9e9e9e"

set output "graph.tex"

set xlabel "x $x$ [$\mu$s]"
set ylabel 'Spot size $\sigma$ [\AA]'
set yrange [-1.1:1.1]

#plot
plot sin(x) notit lw 5, \
    cos(x) notit lw 50 lc rgb "#77ff0000", \
    .5*sin(.9*x) notit lw 30 lc rgb "#200000ff"

unset output

只需 运行 配置文件上的 gnuplot,然后是 pdflatex graph.tex

我在 Mac 上通过 MacPorts 使用 gnuplot 5.4 补丁 2。

谢谢。

拉多万

我可以重现你的问题,但我不太明白为什么灰色背景部分被白色覆盖......无论如何,有一个解决方法:而不是摆弄 [=13] 的 background 选项=], 你可以放置一个具有所需颜色的矩形:

set object rectangle from screen 0,0 to screen 1,1 behind fc "#9e9e9e"

令人惊讶的是,这又产生了另一个问题:由于某种原因,抽动标签被隐藏了。为了纠正这一点,必须指定 set tics front.

因为你是运行通过pdflatex输出的,应该不需要制作eps,直接用pdf代替即可。因此,完整代码为:

reset session

set terminal cairolatex rounded size 5,3 font ',17' standalone 
set output "graph.tex"

set xlabel "x $x$ [$\mu$s]"
set ylabel 'Spot size $\sigma$ [\AA]'
set yrange [-1.1:1.1]
set tics front

set object 1 rectangle from screen 0,0 to screen 1,1 behind fc "#9e9e9e"

#plot
plot sin(x) notit lw 5, \
    cos(x) notit lw 50 lc rgb "#77ff0000", \
    .5*sin(.9*x) notit lw 30 lc rgb "#200000ff"

unset out

设置lc 似乎导致白色矩形。如果检查 eps,所有具有这种线条颜色的曲线都包含为像素化图像而不是矢量图像。

您可以像这样解决问题:

#!/usr/local/bin/gnuplot

set terminal cairolatex eps rounded size 5,3 font ',17' standalone background "#9e9e9e"

set output "graph.tex"

set xlabel "x $x$ [$\mu$s]"
set ylabel 'Spot size $\sigma$ [\AA]'
set yrange [-1.1:1.1]

#plot
plot cos(x) notit lw 50 lt 7 , \
     sin(x) notit lw 5 lt 1, \
     .5*sin(.9*x) notit lw 30 lt 14

unset output

部分解释为什么使用 lc rgb "#77ff0000" 会导致问题

颜色规范 rgb "#77ff0000" 是部分透明红色的正确 gnuplot ARGB 语法。原始绘图命令应该适用于所有支持透明的终端类型。不幸的是,cairolatex 的 eps 变体不是其中之一,因为 PostScript 语言本身不支持透明度。下面的一些图形层(不确定在这种情况下是 cairo 还是 latex)试图通过用图形的那部分逐位近似代替它来模拟它,但做得很差。

解决方案是避免使用 alpha 通道输出的任何 PostScript 变体。您应该可以接受

  set term cairolatex pdf
  set term tikz