# gnuplot epslatex pdflatex

I'm trying to embed my plot created in gnuplot. Just setting the terminal to latex works fine but only creates a black and white plot. With the color screens getting cheaper these days this isn't quite satisfying :D

The manual also mentions the possibility to use epslatex, then converting the eps file to a pdf file and include the generated latex file completely messes up the spacing between the labels on the axis and the actual graph. This happens both times, when creating a latex file for inclusion and also when creating a standalone file.

Guessing that I'm not the only one I ask myself what I am doing wrong and weather there is an easy workaround.

-
`set terminal pdf` is accepted –  egreg Jul 14 '11 at 8:19
Please add a minimal working example (MWE) that illustrates your problem. Include the plot file and the commands you run. –  Andrey Vihrov Jul 14 '11 at 8:20
@egreg: This would likely deny the option to use the document's fonts (I can see that you can only pre-set one font for the `pdf` terminal) and also to include TeX macros in labels. –  Andrey Vihrov Jul 14 '11 at 8:23
@Andrey Vihrov take any plot, set the terminal to epslatex standalone and run gnuplot. Convert the eps file to pdf using eps2pdf then run pdflatex on the tex file generated. –  Nils Jul 14 '11 at 8:25
@Nils: With my previous comment I meant that `set terminal epslatex color; set output "plot.tex"` and `\input{plot}` in the main document worked for me. But now I tested the `standalone` option, and it still works here. I have gnuplot 4.4. –  Andrey Vihrov Jul 14 '11 at 8:35

There are several tools for EPS to PDF conversion: at least `ps2pdf`, `epspdf` and `epstopdf`. It can be verified that the first one of these (which uses GhostScript) creates a PDF of page size (say, A4 or US Letter) and not content size, while the other two work as expected. Some internet digging shows that GhostScript accepts the `-dEPSCrop` option, which clips the picture to its bounding box.
So, use either of `epspdf`, `epstopdf` or `ps2pdf -dEPSCrop` to properly convert the picture.