||
最近想尝试让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
效果如图:
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-10-20 01:42
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社