for distrib in "uniform" "correlated" "clustered"
do
gnuplot << EOF
# gnuplot preamble omitted for brevity
set output "../plots/$distrib-$eps-$points.pdf"
set title "$distrib distribution, eps = $eps, #points = $points"
plot "../plots/dat/$distrib-$eps-$points.dat" using 1:(\$2/$points) title "exact NN"
EOF
done
关于Sven Marnach的解决方案中的$(在shell中,EOF之间的行被称为“here script”):在我的经验中,人们像往常一样使用shell变量,但是对于gnuplot本身的$s必须转义。
下面是一个例子:
注意,反斜杠是美元的转义符,以便gnuplot看到它。
您可以将gnuplot脚本转换为shell脚本,方法是在行前加上
附加行
并用
\$
替换每个$
。然后,可以用$1
替换文件名的每个出现,并用文件名作为参数调用shell脚本。一个简单的方法是生成500个gnuplot脚本,如下所示:
其中
script_text
是gnuplot脚本的文本,文件名替换为%s
。相关问题 更多 >
编程相关推荐