[Tex/LaTex] Latex labels in gnuplot and pdf output

gnuplotpdfterminal-output

I was wondering if is possible to have latex labels in Gnuplot but with pdf output instead .tex

Thanks.

Best Answer

I may reply a bit too late, however, I had the same problem and I've found the solution here.

Basically you need to add a single additional key "standalone" to your terminal definition. I provide a MWE below (script.gp):

set terminal epslatex size 3.5,2.62 standalone color colortext 10
set output 'example.tex'
plot sin(x)

After that you run three more commands:

gnuplot script.gp
latex example.tex
dvips -o example.ps example.dvi

Finally, you can convert the resulting file to pdf. This is probably not the most optimal way to do what you need, however, it works.

UPDATE: Actually, that was a very long way to do this due to my lack of experience. You can reduce the number of steps like this:

gnuplot script.gp
latex example.tex
dvipdf example.dvi example.pdf

However, for some reason dvipdf started giving an empty pdf document some time ago (and I have no desire to dig deeper). You also can use latex directly through pdflatex, however, I get two pdf output files, one of them has no labels at all.