2014-12-03 25 views
-1

我有.gp文件中的GNUplot腳本。如何在終端中指定數據 - 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

無需再提出類似的問題。不過,你的問題是[如何將命令行參數傳遞給gnuplot?](http://stackoverflow.com/q/12328603/2604213)。 – Christoph 2014-12-03 21:19:23

回答

0

這是很久以前我最後一次使用它了。無論如何,我想這應該能夠很好地工作標準輸入文件,你可以這樣做在飛行中通過SED或正常shell變量SUBST這樣的換人:

$> x=uu; sort -u<<EOF 
> a 
> gg 
> ${x} 
> yy 
> dd 
> EOF 
a 
dd 
gg 
uu 
yy 

如果你把你的gnuplot腳本中shell腳本並將使用「Here Document」技術。

製作例如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 
+0

嗯我是新來的Linux我不明白:D你可以解釋一下嗎? – Mirko 2014-12-03 21:00:26

+0

查看更新。 – 2014-12-03 21:23:29

相關問題