GNUPLOT:跟随命令到下一行?
GNUPLOT: Follow command to the next line?
我有以下名为 tmp.plt
的 gnuplot 脚本:
plot \
"n300_50int/ini-ene.his" using 1:2, \
"n500_100int/ini-ene.his" using 1:2, \
"n500_1ooint_0.65e3/ini-ene.his" using 1:2, \
"n500_50int/ini-ene.his" using 1:2
但它给了我错误
samuel@samuel-P5Wx6:~/Documents/Fisica/19-20/Radiactividad/Prácticas/Practicas-MontCarlo/PET/Simulaciones$ gnuplot -p tmp.plt
plot "n300_50int/ini-ene.his" using 1:2, \
^
"tmp.plt", line 2: invalid character \
我用以下 .sh 创建了这个脚本(根据 Gnuplot: Plot several in files in different folders 中的那个编辑):
#!/bin/bash
## truncate tmp.plt and set line style
echo -e "plot \" > tmp.plt
cnt=0 ## flag for adding ', \' line ending
## loop over each file
for i in */ini-ene.his; do
if ((cnt == 0)); then
cnt=1
else
printf ", \ \n" >> tmp.plt
fi
printf "\"$i\" using 1:2" >> tmp.plt
done
echo "" >> tmp.plt
而且我不明白为什么在下一个 test.plt
文件运行时它不起作用
f(x)=x
g(x)=2*x
plot \
f(x) , \
g(x)
谢谢!
由于 tmp.plt
文件中的反斜杠 (\
) 而出错。原因是根据 gnuplot
说明,\
需要成为该行的最后一个字符。在非工作示例中,\
之后有一个 space。如果在工作示例中的 \
之后添加 space,它也会出错。如图所示:
plot f(x) , \
^
"test.plt" line 4: invalid character \
所以尝试:
printf ",\\n" >> tmp.plt
(或 printf ",\n" >> tmp.plt
)
而不是:
printf ", \ \n" >> tmp.plt
我有以下名为 tmp.plt
的 gnuplot 脚本:
plot \
"n300_50int/ini-ene.his" using 1:2, \
"n500_100int/ini-ene.his" using 1:2, \
"n500_1ooint_0.65e3/ini-ene.his" using 1:2, \
"n500_50int/ini-ene.his" using 1:2
但它给了我错误
samuel@samuel-P5Wx6:~/Documents/Fisica/19-20/Radiactividad/Prácticas/Practicas-MontCarlo/PET/Simulaciones$ gnuplot -p tmp.plt plot "n300_50int/ini-ene.his" using 1:2, \ ^ "tmp.plt", line 2: invalid character \
我用以下 .sh 创建了这个脚本(根据 Gnuplot: Plot several in files in different folders 中的那个编辑):
#!/bin/bash
## truncate tmp.plt and set line style
echo -e "plot \" > tmp.plt
cnt=0 ## flag for adding ', \' line ending
## loop over each file
for i in */ini-ene.his; do
if ((cnt == 0)); then
cnt=1
else
printf ", \ \n" >> tmp.plt
fi
printf "\"$i\" using 1:2" >> tmp.plt
done
echo "" >> tmp.plt
而且我不明白为什么在下一个 test.plt
文件运行时它不起作用
f(x)=x
g(x)=2*x
plot \
f(x) , \
g(x)
谢谢!
由于 tmp.plt
文件中的反斜杠 (\
) 而出错。原因是根据 gnuplot
说明,\
需要成为该行的最后一个字符。在非工作示例中,\
之后有一个 space。如果在工作示例中的 \
之后添加 space,它也会出错。如图所示:
plot f(x) , \
^
"test.plt" line 4: invalid character \
所以尝试:
printf ",\\n" >> tmp.plt
(或 printf ",\n" >> tmp.plt
)
而不是:
printf ", \ \n" >> tmp.plt