# Inserting graph from gnuplot to latex

How to insert high quality graph drawn in GNUplot in LaTeX. I am trying to use following method:

1. draw graph in gnuplot
2. saving it as SVG file
3. converting svg into pdf
4. Inserting pdf into latex file

However, I am unable to include greek letters in the SVG file? Can someone help me?

• Do you have a particular reason for not exporting directly to PDF using the pdfcairo terminal, or using the cairolatex terminal? – Jake Oct 21 '14 at 10:44
• This question has nothing to do with latex3 in my point of view – user31729 Oct 21 '14 at 10:48
• Note that there is a convenient gnuplottex package that allows you to embed gnuplot code directly in your TeX code. – TonioElGringo Jul 8 '15 at 7:21
• This doesn't answer your question, but you may want to have a look at the pgfplots package, which lets you draw high quality graphs in LaTeX. The main advantage of using the package is that it has a proper interface with LaTeX and lets you define styles, so you can draw graphs in the same consistent style. – user10274 Aug 7 '15 at 6:46
• @MarcvanDongen: No worries: I did not came back to this question to delete my comment above. – user31729 Aug 7 '15 at 9:27

Do you need to make changes to the image at the SVG stage? If not then you could simply export your graph as a PDF following the instructions here. However, you may prefer to use GNUplot's epslatex output mode an input the figure that way, this would give you much better control over the text elements of the graph since the are controlled by LaTeX. Instruction for doing this can be found here.

• Yes, I need to make changes to the image at the SVG state – mani Oct 21 '14 at 10:52
• What changes do you need to make, are these related to the textual or image elements of the figure? Either way you may want to look at the LaTeX terminal mode as you should be able to make the changes you want to either the EPS or the tex file generated. Why exactly are you unable to include greek in your current method? If you are using inkscape you can insert any unicode character. – Tom Brien Oct 21 '14 at 10:57
• Cairolatex and/or epslatex or even the tikz terminal should be far better than the latex terminal. See ftp.rrzn.uni-hannover.de/pub/mirror/tex-archive/macros/latex/… for examples. – John Oct 21 '14 at 14:31
• @John sorry I meant epslatex, will edit now. – Tom Brien Oct 21 '14 at 14:36

Assuming you really want svg: In newer versions of inkscape you can export the text separately. That is you get a .pdf file that only contains the image-information and a .pdf-tex that contains latex-commands to overlay the text. The big advantage then is that you have full access to latex functionalities. You could for example say in gnuplot

set xlable '$\sum\xi^\Xi$'
set term svg ....; set out 'mysvg.svg'
#plot something


and then you go to inkscape or use console

inkscape mysvg.svg --export-pdf mypdf.pdf --export-latex


which also creates mypdf.pdf_tex and then say

\begin{figure}
\input{mypdf.pdf_tex}