Graphics, Figures & Tablestikz - gnuplot integration

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
CoolnessItself
Posts: 47
Joined: Wed Nov 11, 2009 9:30 pm

tikz - gnuplot integration

Post by CoolnessItself »

Using the following code:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[color=blue] plot[id=sin] function{sin(x)} node[right] {$f(x)  = \sin x$};
\end{tikzpicture}
\end{document}
compiled with
--shell-escape --enable-write18

I don't get a plot, only the text. My log file has lines
runsystem(gnuplot test.sin.gnuplot)...executed.
Package pgf Warning: Plot data file `test.sin.table' not found. on input line 7

So it sounds like gnuplot makes a .gnuplot file and pgf is looking for a .table file (right?). If I rename test.sin.gnuplot to test.sin.table and recompile, I get
! Package PGF Math Error: Unknown function `set'.

I've tried editing line 288 of
C:\Program Files (x86)\MiKTeX 2.8\tex\generic\pgf\modules\pgfmoduleplot.code.tex from
set terminal table
to
set table
as some threads have suggested, same result.
gnuplot is in my %PATH%.


Any suggestions?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tikz - gnuplot integration

Post by localghost »

CoolnessItself wrote:Using the following code […] compiled with
--shell-escape --enable-write18 […]
For MiKTeX use only the latter one.
CoolnessItself wrote:[…] I don't get a plot, only the text. My log file has lines
runsystem(gnuplot test.sin.gnuplot)...executed.
Package pgf Warning: Plot data file `test.sin.table' not found. on input line 7

So it sounds like gnuplot makes a .gnuplot file and pgf is looking for a .table file (right?). If I rename test.sin.gnuplot to test.sin.table and recompile, I get
! Package PGF Math Error: Unknown function `set'. […]
Quite logical. Gnuplot actually should generate a *.table file so that renaming is not necessary. But this file is only generated if the terminal is set correctly in the *.gnuplot file that is generated by pgf/tikZ (or pgfplots).
CoolnessItself wrote:[…] I've tried editing line 288 of
C:\Program Files (x86)\MiKTeX 2.8\tex\generic\pgf\modules\pgfmoduleplot.code.tex from
set terminal table
to
set table
as some threads have suggested, same result. […]
This patch is only needed for Gnuplot 4.4.0 and higher. Its functionality seems to be proved.
CoolnessItself wrote:[…] gnuplot is in my %PATH%. […]
Please clarify which version of Gnuplot you are using.

For the present you may use the internal plot mechanism of the package. For details see the package manual.

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw[color=blue] plot (\x,{sin(\x r)}) node[right] {$f(x) = \sin x$};
  \end{tikzpicture}
\end{document}

Best regards
Thorsten
Post Reply