liuzhongli的个人博客分享 http://blog.sciencenet.cn/u/liuzhongli

博文

让Gnuplot绘图实现准可视化

已有 4394 次阅读 2013-3-7 22:10 |个人分类:Linux|系统分类:科研笔记

最近想尝试让GNUplot实现编辑过程中动态修改可视化,这样就不用一遍遍地修改GNUplot的输入文件,再执行生成图片文件了,最终的效果是:在用vim修改Gnuplot脚本内容的同时结果立即呈现在图片中。

需要SumatraPDF,epstopdf,vim。
让vim自动保存修改过的内容,需在.vimrc中加入以下内容:

:au! CursorHoldI,CursorHold  silent! :update
:set updatetime=500


脚本如下:

#########################################################################

#! /bin/bash

bn=$@

if [ $# -eq 0 ]; then
echo "USAGE: gp basename"
echo "MAKE SURE: gnuplot script has bn.plt format!"
echo "MAKE SURE: and in bn.plt the .eps file has bn.eps format!"
exit
fi

i=1
gnuplot $bn.plt
epstopdf $bn.eps
SumatraPDF.exe $bn.pdf 2>/dev/null &
gvim $bn.plt
while true ;do

   initial_time=`stat -c "%Y" $bn.plt`
   sleep 1
   final_time=`stat -c "%Y" $bn.plt`

   if [ $initial_time -ne $final_time ] ;then
       echo "Plot changed $i times."
       gnuplot $bn.plt 2>/dev/null
       epstopdf $bn.eps
       i=$(($i+1))
   fi

done

#########################################################################

把脚本写入文件如:gp.sh,并加执行权限: chmod +x gp.sh
使用方法: ./gp.sh input,就可以实现准可视化了。

GNUplot 的输入文件名为input.plt


效果如图:





https://wap.sciencenet.cn/blog-873681-668152.html

上一篇:计算模拟常用网址(备忘)
下一篇:用(g)vim编写latex文章的自动英语拼写提示(备忘)
收藏 IP: 61.136.68.*| 热度|

1 王振亭

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-3-29 21:55

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部