[英]Use a Gnuplot variable instead of Bash Variable in a bash script + gnuplot script
您好我想在bash脚本中使用gnuplot绘制smth,所以我有:
#!/bin/bash
//myscript
gnuplot -persist <<-EOFMarker
plot 'd.csv' using 3:xtic(1) with boxes notitle, 'd.csv' using 0:($3+100):3 with labels
EOFMarker
我的问题是脚本替换($ 3 + 100)来自bash变量(没有+ 100)而不是来自gnuplot(来自第3列+ 100的每个值)..如何更改脚本以便使用来自gnuplot的变量? 非常感谢
它应该工作, $3
是空的,考虑这个:
#!/bin/bash
set a b world
cat <<-EOF
hello $3
EOF
将输出hello world
。 如果你想向命令发送$3
,你需要逃避美元符号:
#!/bin/bash
set a b world
cat <<-EOF
hello \$3
EOF
使用column
函数,然后你不必关心转义: $2
是column(2)
的快捷方式。
gnuplot -persist <<-EOFMarker
plot 'd.csv' using 3:xtic(1) with boxes notitle, 'd.csv' using 0:(column(3)+100):3 with labels
EOFMarker
顺便说一句:在绘制标签时,您可以使用offset
选项指定偏移量,例如以字符为单位:
gnuplot -persist <<-EOFMarker
plot 'd.csv' u 0:3:xtic(1) w boxes t '', '' u 0:3:3 w labels offset 0, char 1
EOFMarker
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.