在gnuplot

时间:2017-05-26 20:09:16

标签: bash scope gnuplot

我尝试使用重读命令创建带有gnu图的实时动画。

我的主程序输出一系列数据文件,如

 0.0000000.dat
 0.1000000.dat 
 10.500000.dat

等。我希望脚本能够连续绘制每个文件并在文件用完时停止(暂停在最后一个文件上)。

这是我到目前为止所拥有的。 Get_File_Name是一个bash函数,可以正确格式化文件名。

source ~/Source_Me/*.sh

shopt -s expand_aliases

### Process input parameters
if [ "$1"  ];
then
        Time=$1
else
        echo "No start time detected, starting at 0.0"
        Time=0.0
fi

if [ "$2"  ];
then
        Increment=$2
else
        echo "No time increment specified. choosing 0.1" 
        Increment=0.1
fi

if [ "$3" ];
then
        FrameDelay=$3
else
        echo "No frame delay time specified, choosing 0.25 s"
        FrameDelay=0.35
fi



FileName=$(Get_File_Name $Time orbs)
        # Do this from command line
        #Do the plotting
gnuplot << EOF
t = $Time       
print t
        set pm3d map
        splot "$(Get_File_Name $Time orbs)" u 1:2:8


        pause 1 
       ### Increment the time somehow
       ### reread conditionally upon the existence of the next file
EOF

我知道您可以使用

在gnu plot中调用bash函数
system "<command>"

但这会创建一个无法操纵现有变量的新环境。 我无法弄清楚如何操纵gnu绘图块中的bash变量。

    gnuplot << EOF
     EOF

如何在gnuplot块中增加时间和文件名变量?

1 个答案:

答案 0 :(得分:0)

我发现了这个相关的问题:

Loop structure inside gnuplot?

这给了我一个可行的解决方案。使用

构建文件名列表就足够了,而不是更新文件名

list = system('ls -1B *orbs.dat | sort -n ')

我认为使用system()而不是system ""可以将bash行的输出保存为gnuplot变量。