[原创] 在gnuplot里使用中文标注

OOo,TeX,KO,ABI,GIMP,Picasa,ProE,QCAD,Inkscape,Kicad,Eagle
回复
头像
marsteel
帖子: 555
注册时间: 2005-11-28 12:09
联系:

[原创] 在gnuplot里使用中文标注

#1

帖子 marsteel » 2007-05-11 11:06

http://magang.name

解决了gnuplot下使用中文字符的问题,在Ubuntu 7.04环境下介绍一下方法:
使用gnuplot-4.2,如果不是这个版本,到http://www.gnuplot.info下载最新版,编译运行。

代码: 全选

  $gnuplot
  gnuplot> set term png font "/usr/share/fonts/truetype/chinese/simsun.ttc,12"
  Terminal type set to 'png'
  Options are 'nocrop font /usr/share/fonts/truetype/chinese/simsun.ttc 12 xffffff x000000 xa0a0a0 xff0000 x00c000 x0080ff xc000ff x00eeee xc04000 xeeee00 x2020c0 xffc020 x008040 xa080ff x804000 xff80ff x00c060 x00c0c0 x006080 xc06080 x008000 x40ff80 x306080 x806000 x404040 x408000 x000080 x806010 x806060 x806080 x0000c0 x0000ff x006000 xe3b0c0 x40c080 x60a0c0 x60c000 x60c0a0 x800000 x800080 x602080 x606060 x202020 x204040 x204080 x608020 x608060 x608080 x808040 x208020 x808080 xa0a0a0 xa0d0e0 xc02020 x008080 xc06000 x80c0e0 xc060c0 xc08000 xc08060 xff4000 xff4040 x80c0ff xff8060 xff8080 xc0a000 xc0c0c0 xc0ffc0 xff0000 xff00ff xff80a0 xc0c0a0 xff6060 x00ff00 xff8000 xffa000 x80e0e0 xa0e0e0 xa0ff20 xc00000 xc000c0 xa02020 xa020ff x802000 x802020 x804020 x804080 x8060c0 x8060ff x808000 xc0c000 xff8040 xffa040 xffa060 xffa070 xffc0c0 xffff00 xffff80 xffffc0 '
   gnuplot> set title "中文标题"
   gnuplot> set output "chstitle.png"
   gnuplot> plot sin(x)
打开chstitle.png,就可以看到中文了!
/usr/share/fonts/truetype/chinese/是我Ubuntu上保存Windows XP(TM)字体的文件夹.另有2个环境变GDFONTPATH和GNUPLOT_DEFAULT_FONT可以设置,可以简化字体设置.

代码: 全选

 $export GDFONTPATH=/usr/share/fonts/truetype/chinese/
如果需要永久设置GDFONTPATH,可以修改/etc/profile,环境变量保存于此文件中.

代码: 全选

 $sudo gedit /etc/profile
在文件尾部添加一行

代码: 全选

GDFONTPATH=/usr/share/fonts/truetype/chinese/
测试一下:

代码: 全选

   1. $gnuplot
   2. gnuplot> set term png font "simsun.ttc,12"
   3. Terminal type set to 'png'
   4. Options are 'nocrop font simsun.ttc 12 '
   5. gnuplot> set title "中文标题"
   6. gnuplot> set output "defaultfont_chstitle.png"
   7. gnuplot> plot sin(x)
GNUPLOT_DEFAULT_FONT我没有测试成功,但理论上是可以设置默认字体的。如果你成功了,请告诉我.:)
回复