2

I have looked at numerous posts about this topic and have yet to find an answer. I'm usually quite resilient to these kind of problems but have to admit to defeat on this one. I cannot turn a .dat file into decent latex code. My gnuplot input code looks like

plot "file.dat" using 1:6 with lines
set terminal epslatex
set output "output.tex"
set label "$\alpha$"
set out

This produces a .tex and a .eps file as required. I now compile a plot.tex file with pdflatex and the following code:

\documentclass{article}
\usepackage{graphics}
\usepackage{epstopdf}

\begin{document}
\include{output.tex}
\end{document}

When I open the plot.pdf there is nothing there. There are no errors in the pdflatex complilation either. The .dat definitely has data and I believe the issue is with the gunplot code; I can't plot the .dat file inside the epslatex terminal and the corresponding .eps file is empty. If someone could tell me how to do this that would be great. I can save the data quite easily as an .eps file but I really want the latex xlabels etc.

Cheers

Jack

0

1 Answer 1

1

Several issues:

  • When you issue the gnuplot command plot, it makes the plot then and there however it has been configured. You are doing this at the very beginning of your script before configuring anything at all. Define your terminal type, titles, ranges, etc. towards the beginning, then put the plot command at the end. This may seem confusing, but a gnuplot script is just that: a script. It executes one line after another. This allows you to change settings after a plot command and then make another plot (i.e. to a different output file) somewhere else with slightly different settings.

  • The instruction set out is short for set output (...to nothing). I'm not sure why you would want to set the output to nothing after you just did set output "output.tex".

  • You probably want a title or axis label of "α" instead of a label of "alpha". You set the title with set title. There are also x- and y-axis labels you can set with set xlabel and set ylabel. gnuplot has actual "labels", but this has a certain technical meaning (text placed at a particular coordinate).

  • Maybe you intended to label the data set "α" instead of title the plot "α". Then append title "$\\alpha$" to the plot line. gnuplot will invent a title unless you specify one or use the keyword notitle.

  • You have to escape the backslash (\\ instead of \) in strings in gnuplot if you want to give it to LaTeX. Use $\\alpha$ instead of $\alpha$.

In summary, try something like this:

set terminal epslatex
set output "output.tex"
set title "Impressive Results of $\\alpha$"
plot "file.dat" with lines title "$\\alpha$"

Also, I had trouble with \include{output.tex} in your LaTeX document. You shouldn't need to specify the file extension. I'm used to using the graphicx package, but to each his own. So this worked for me:

\documentclass{article}
\usepackage[pdftex]{graphicx}

\begin{document}
\include{output}
\end{document}

I hope this gets you started with something working.

Sign up to request clarification or add additional context in comments.

1 Comment

\include{output} is right. Adding the file extension confuses LaTeX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.