一个 bash/gnuplot 脚本来产生类似电影的效果

A bash/gnuplot script to produce movie-like effects

我想使用 gnuplot 在同一个 window 上一个接一个地绘制一系列图像。图片的大小完全相同,我有很多按顺序称为 test_0X.gnu 并且采用 gnuplot 格式。

我写在 bash

 #! /bin/bash

for i in $(seq -f "%06g" 0 1000)
do
echo "set term pdf enhance color" > script.plg
echo "set output 'demo.pdf'" >> script.plg

echo "plot 'test_$i.gnu' with lines" >> script.plg
echo "set output"

gnuplot < script.plg

evince demo.pdf &
sleep 0.3

done;

seq -f 确保在数字之前存在正确数量的填充零。

这行得通,但是一旦脚本启动,我就无法停止它,因为 ctrl+cctrl+z 不起作用,而且由于不断出现 pdf [,我无法访问其他终端 windows.

只需编写一个简短的 gnuplot 脚本

set terminal wxt
files = system('ls test_*.gnu')
do for [file in files] {
    plot file with lines
    pause 0.5
}

和运行这个

gnuplots "gif" 终端可以制作现成的动画。

skip=5 # change as needed
set term gif animate 10 # 10/100 s delay between frames
set out "test.gif"
# assuming your data files are named "test_0001.dat" etc.
do for [i=1:100:skip] {plot sprintf("test_%04.f.dat",i)}
set out