osx 中的 gnuplot 和 texshop
我已经通过 macports 安装了 gnuplot,但是当我在 texshop 中编译我的 Latex 文档时,它没有显示绘图,并且我在日志文件中收到这些错误:
Package pgf Warning: Plot data file `tutorial.x.table' not found. on input line
17.
Package pgf Warning: Plot data file `tutorial.sin.table' not found. on input li
ne 19.
Package pgf Warning: Plot data file `tutorial.exp.table' not found. on input li
ne 21.
我只是想编译这个基本示例:
% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
% GNUPLOT required
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot[id=x] function{x}
node[right] {$f(x) =x$};
\draw[color=blue] plot[id=sin] function{sin(x)}
node[right] {$f(x) = \sin x$};
\draw[color=orange] plot[id=exp] function{0.05*exp(x)}
node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}
\end{document}
I have installed gnuplot through macports but when i compile my latex document in texshop it doesn't show the plots and I get these errors in the log file:
Package pgf Warning: Plot data file `tutorial.x.table' not found. on input line
17.
Package pgf Warning: Plot data file `tutorial.sin.table' not found. on input li
ne 19.
Package pgf Warning: Plot data file `tutorial.exp.table' not found. on input li
ne 21.
I'm just trying to compile this basic example:
% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
% GNUPLOT required
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[domain=0:4]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw[color=red] plot[id=x] function{x}
node[right] {$f(x) =x$};
\draw[color=blue] plot[id=sin] function{sin(x)}
node[right] {$f(x) = \sin x$};
\draw[color=orange] plot[id=exp] function{0.05*exp(x)}
node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}
\end{document}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您需要将 tikz 创建的 .gnuplot 文件转换为表格文件。为此,您有两种选择:
您可以使用附加命令行开关 --shell-escape(有时也称为 --enable-write-18)运行 (pdf)latex,然后 gnuplot 会自动为您运行。 (不过,您可能不愿意允许从 pdflatex 中启动任意程序。)
您可以自己在 test.exp.gnuplot、test.sin.gnuplot、test.x.gnuplot 等文件上运行 gnuplot 。只需
gnuplot test.exp.gnuplot
就可以了。 (这里无法验证,因为我的 gnuplot 版本太旧了。)Yes, you need to turn the .gnuplot files that tikz creates into the tables files. You have two choices for this:
you can run (pdf)latex with the additional command line switch --shell-escape, sometimes also called --enable-write-18, then gnuplot is run automatically for you. (You might not be comfortable with allowing arbitrary programs to be starte from within pdflatex, though.)
you can run gnuplot yourself on the test.exp.gnuplot, test.sin.gnuplot, test.x.gnuplot etc. files. Simply
gnuplot test.exp.gnuplot
should do it. (Can't verify here, since my gnuplot version is too old.)