TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following minimal example shows how I make a plot using gnuplot to the "epslatex" terminal and want to include it in my document. However, the axis texsts do not show.. What might be wrong? Gnuplot makes a .tex file and an .eps file. I should have thought it was going to use both when converting to PDF. This is pdflatex by the way.

set format "$%g$"
set xlabel "Temperature $T_t$"
set ylabel "Difference $|f(s')-f(s)|$"
set xrange [0.1:20]
set yrange [1:20]
set zrange [0:1]
set terminal epslatex
set output "prob.eps"
splot exp(-y/x) title ""

share|improve this question
At the moment you're just including the EPS file, because you're using \includegraphics. You need to include the .tex file, which will in turn include the EPS. Try \include{prob} or \input{prob}. – Jake Jun 7 '12 at 11:19
Ah, right. This gives me something but the placing of the labels is completely off! – Martin Lauridsen Jun 7 '12 at 11:53
up vote 3 down vote accepted

The epslatex terminal produces two files: A .tex file with the labels, and an .eps file with the graphical elements. The .tex file inserts the .eps file itself, so all you have to do is insert the .tex file using \include or \input.


Instead of trying to figure out how to correct the label placement, may I suggest you give PGFplots a try? It can create plots of many mathematical functions and of data within LaTeX, and if you need really complicated mathematics, it can use gnuplot as a back end. The advantage of PGFplots over the epslatex terminal is that it's much easier to adjust the appearance of the plots. Your plot could be created using


    width=10cm, height=6cm,
    domain=0.1:20, xmin=0,
    y domain=1:20,
    xlabel=Temperature $T_t$,
    ylabel=Difference $|f(s')-f(s)|$,
    ylabel style={anchor=west},
\addplot3 [surf] {exp(-y/x)};

Compiling this with pdflatex will yield

share|improve this answer
Wow, thats really sweet! I need to look more into the manual. Can you tell me how I'd stretch the plot so its wider ratio wise? – Martin Lauridsen Jun 7 '12 at 12:27
For stretching the plot, you can set width=<value> and height=<value>. If you only set one of the two options, the plot will be scaled proportionally. – Jake Jun 7 '12 at 12:29
Okay, just a follow up. Ever since I put this plot in my document, it takes sooo long to compile. I am using the texstudio editor with its built-in pdf previewer, and it seems this previewer is trying to load the pdf like 6 times, and each time I get a dialog saying the source is not a valid pdf. Of couse, this is probably not latex related per se, but if it is because of the plot itself, maybe there is something I can do. – Martin Lauridsen Jun 8 '12 at 12:07
That error dialog is a bit strange, that shouldn't happen. To speed up compilation, you can put \usetikzlibrary{external} \tikzexternalize into your preamble, then the graph will be compiled into a separate pdf on the first run. On subsequent runs, only that pdf will be included, instead of having to recalculate the whole plot. If you want to change something about the plot, you'll have to put \tikzset{external/remake next} in front of the \begin{tikzpicture} to update the externalized pdf. – Jake Jun 8 '12 at 12:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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