Search code examples
latexgnuplotbeamer

gnuplot: cairolatex background issues


I am having problem with cairolatex terminal in gnuplot.

I am setting my terminal as follows:

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

The background is set up properly outside of the plot, but remains white inside of the plot area. I have also tried "transparent" with the same problem. Basically, the automatically generated file filename-inc which is included in the latex is incorrect.

In the attached picture you see grey background of the beamer slide with include pdf generated with gnuplot via cairolatex.

It drives me crazy.

Edit: Here is minimal code.

#!/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

Just run gnuplot on the config file followed by pdflatex graph.tex

I am using gnuplot 5.4 patch 2 on Mac via MacPorts.

Thank you.

Radovan

enter image description here


Solution

  • Partial explanation why using lc rgb "#77ff0000" causes problems

    The color specification rgb "#77ff0000" is correct gnuplot ARGB syntax for partially transparent red. The original plot commands should work as intended for all terminal types that support transparency. Unfortunately the eps variant of cairolatex is not one of those because the PostScript language itself does not support transparency. Some graphics layer underneath (not sure whether it's cairo or latex in this case) tries to dummy it up by substituting a bit-by-bit approximation for that part of the graphic but does a very poor job of it.

    The solution is to avoid any variant of PostScript for output that uses an alpha channel. You should be OK with either of

      set term cairolatex pdf
      set term tikz