2

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?

  • 4
    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
  • 3
    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
  • 1
    @MarcvanDongen: No worries: I did not came back to this question to delete my comment above. – user31729 Aug 7 '15 at 9:27
2

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
  • 1
    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
1

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}
\caption{Stackexchange is really helpful}
\end{figure}

in your latex document.

One problem with this approach is that you might get into situations where you need your figure to be self-contained (some journals are ridiculuos for example). For this purpose I have written a tiny bash script that sets up a new .tex document with the figure in it and compiles it so that the result is a pdf with the text on it. (kind of like the old fig2pdf but with svg s)

0

As others have pointed out, if you need to make changes after plotting, then SVG is an acceptable solution. If not, PDF, or better still: gnuplot's epslatex terminal will be best. See here, and if you can have also look at the explanation of this in the book "Gnuplot in Action", by P. Janert.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.