我使用以下脚本生成一个简单的eps图像:
set terminal epslatex 8 set output 'sample1.tex' set size 0.75,0.75 set xrange [-pi:pi] set yrange [0:1.2] set xlabel "$x$" set ylabel "$y$" plot sin(x)*sin(x) title "$\\sin^2(x)$"
但是,当我在gnuplot中运行它时
gnuplot> load "sample.gpi"
我得到一张空白图片,只显示没有数字的网格.有什么建议我做错了什么?
您可能正在查看该sample1-inc.eps
文件.但是您必须首先编译输出LaTeX文件.为此,使用该standalone
选项并在脚本本身内编译非常方便:
set terminal epslatex 8 standalone set output 'sample1.tex' set size 0.75,0.75 set xrange [-pi:pi] set yrange [0:1.2] set xlabel "$x$" set ylabel "$y$" plot sin(x)*sin(x) title "$\\sin^2(x)$" set output # finish the current output file system('latex sample1.tex && dvips sample1.dvi && ps2pdf sample1.ps')
现在,您可以load 'sample1.gpi'
将完整输出视为sample1.ps
或sample1.pdf
.如果你在Windows上,你可能需要编译三个单独的system
调用(只是猜测):
system('latex sample1.tex') system('dvips sample1.dvi') system('ps2pdf sample1.ps')