我在.gp文件中有一个GNUplot脚本。
set terminal pngcairo enhanced size 5000,500 font 'DejaVuSerifCondensed,11' rounded;
set output 'acc_vrecko_predne.png'
set encoding iso_8859_2
set yrange [-15:15]
set xrange [0:1261]
set xtics 20
set title 'dáta accelerometer - predne vrecko ' font 'DejaVuSerifCondensed-Bold,12'
set samples 7000
set style line 1 lt 1 lw 0.5 lc rgb "red"
set style line 2 lt 1 lw 0.5 lc rgb "blue"
set style line 3 lt 1 lw 1 lc rgb "green"
set datafile separator "|"
plot \
\
'data/vrecko_acc.txt' u 0:2 sm cs w l ls 1 t 'X-suradnice',\
'data/vrecko_acc.txt' u 0:3 sm cs w l ls 2 t 'Y-suradnice',\
'data/vrecko_acc.txt' u 0:4 sm cs w l ls 3 t 'Z-suradnice'
reset
有没有办法在终端中指定数据路径和文件名并从中运行脚本? 我应该改变.gp文件中的内容吗?
THX
答案 0 :(得分:0)
很久以前我最后一次使用它了。无论如何,我想它应该能够与stdin文件一起正常工作,并且你可以通过sed或普通的shell变量替换它,如下所示:
$> x=uu; sort -u<<EOF
> a
> gg
> ${x}
> yy
> dd
> EOF
a
dd
gg
uu
yy
如果您将gnuplot脚本放在shell脚本中并使用&#39; Here Document&#39;技术
创建一个文件,例如my_script.sh,其中包含以下内容:
#!/bin/sh
file1="data/vrecko_acc.txt"
file2="data/vrecko_acc.txt"
file3="data/vrecko_acc.txt"
# or uncomment and use this variant to pass params as args like this:
# sh my_script.sh data/acc1.txt data/acc2.txt data/acc3.txt
# file1="${1}"
# file2="${2}"
# file3="${3}"
gnuplot - <<EOF
<here goes you file, do not forget to put '\'(back slash) before any $ sign>
'${file1}' u 0:2 sm cs w l ls 1 t 'X-suradnice',\
'${file2}' u 0:3 sm cs w l ls 2 t 'Y-suradnice',\
'${file3}' u 0:4 sm cs w l ls 3 t 'Z-suradnice'
reset
EOF