3

I have been trying to make LaTeX plot directly as it compiles the pdf but it always turns out to require me to go to the terminal and process the .gnuplot file that the compilation produces, which is horribly time-consuming. Is there anyway of including the plot in the compilation of the pdf?

I am using Mac OS X 10.10.2 and writing in TeXShop. My code so far is

\usepackage{graphicx}
\usepackage{gnuplottex}

\begin{figure}[h!]
\centering
\begin{gnuplot}[terminal=cairolatex,terminaloptions=color]
set ylabel "y"
plot [0:2*pi] sin(x) title 'Sine', cos(x) title 'Cosine'
\end{gnuplot}
\end{figure}

This produces a filename.gnuplot file but no figure in the .pdf. After I use the terminal ( typing "gnuplot filename.gnuplot"), and compile the LaTeX again the graphs shows up.

Thank you!

TMG
  • 31

1 Answers1

1

Take this

\documentclass[convert=false,border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document} 
\ifpdf
\begin{tikzpicture}
\begin{axis}
\addplot +[raw gnuplot] gnuplot {
set ylabel "y";
plot [0:2*pi] sin(x) title 'Sine', cos(x) title 'Cosine';
};
\end{axis}
\end{tikzpicture}
\fi
\end{document}

:)

  • But what if I want to include it in the main .tex file? And also I take it if I want to plot from a file the command is the same, right? Also thanks! :) – TMG May 08 '15 at 15:19
  • I am not sure about your question. You should ask a new one, try make a clear statement, as clear as possible. Then I will try to help you. ;) – Peter Ebelsberger May 14 '15 at 18:19