Search code examples
gnuplotdollar-sign

Dollar-sign from gnuplot code generates conflict with epslatex


In order to make filled curves only in selected areas of the function parameter (x-axis), I found a good idea with a filter on the thread "Fill several sections below a curve of data in Gnuplot".

The problem is that with epslatex, the used $ sign to point to the variable is creating an error when trying to compile with latex.

Is there any other possibility to address the variable?

set samples 100
set xrange [-2:2]
f(x) = -x**2 + 4

set linetype 1 lc rgb '#A3001E'

set style fill transparent solid 0.35 noborder
filter(x,min,max) = (x > min && x < max) ? x : 1/0
plot '+' using (filter($1, -1, -0.5)):(f($1)) with filledcurves x1 lt 1 notitle,\
     ''  using (filter($1, 0.2, 0.8)):(f($1)) with filledcurves x1 lt 1 notitle,\
     ''  using 1:(f($1)) with lines lw 3 lt 1 title 'curve'

Solution

  • I guess the problem comes from the $ in the automatic title, which is created by gnuplot. Use title to overwrite this by a custom one:

    plot ... title 'my custom escaped title'
    

    Or use column(1) instead of the short cut $1.