gnuplot的妙用

用批处理命令生成出版质量的图片要比点鼠标好很多。但是,图片中插入中文以及公式,由于字体的问题经常会比较困难。

今天发现一个好的方法:利用gnuplot的epslatex terminal,然后用LaTeX或者xeLaTeX编译,接着dvips -E生成eps。这样就可以用LaTeX公式和xeLaTeX的字体了。

例如:

  1. 编辑一个可执行文件testEpslatex.plt如下
  2. set term epslatex standalone color
    set output ‘test.tex’
    set xlabel ‘x’
    set ylabel ‘$f\left(x\right)$’
    f(x)=exp(x) #just as an example
    plot f(x) w l title “$e^{x}$”
    set output
    unset key

  3. 然后运行(可以用makefile,make testEpsLatex)
  4. testEpslatex: testEpslatex.plt
    ./testEpslatex.plt
    latex test.tex #latex can be replaced by xelatex
    latex test.tex
    dvips -E test.dvi
    mv test.ps BACKUP.eps #better to get a unoccupied name
    rm test.*
    rm test-inc.eps
    mv test.ps test.eps

就能够得到test.eps。

《gnuplot的妙用》有一个想法

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注