[英]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.