OSXv10.6.8およびGnuplotv4.4
8列のデータファイルがあります。6列目の最初の値をタイトルにします。これが私がこれまでに持っているものです:
#m1 m2 q taua taue K avgPeriodRatio time
#1 2 3 4 5 6 7 8
K = #read in data here
graph(n) = sprintf("K=%.2e",n)
set term aqua enhanced font "Times-Roman,18"
plot file using 1:3 title graph(K)
そして、これが私のデータファイルの最初の数行がどのように見えるかです:
1.00e-07 1.00e-07 1.00e+00 1.00e+05 1.00e+04 1.00e+01 1.310 12070.00
1.11e-06 1.00e-07 9.02e-02 1.00e+05 1.00e+04 1.00e+01 1.310 12070.00
2.12e-06 1.00e-07 4.72e-02 1.00e+05 1.00e+04 1.00e+01 1.310 12070.00
3.13e-06 1.00e-07 3.20e-02 1.00e+05 1.00e+04 1.00e+01 1.310 12090.00
データを正しく読み取る方法や、これが正しい方法であるかどうかはわかりません。
編集#1
わかりました、mgilsonのおかげで私は今持っています
#m1 m2 q taua taue K avgPeriodRatio time
#1 2 3 4 5 6 7 8
set term aqua enhanced font "Times-Roman,18"
K = "`head -1 datafile | awk '{print $6}'`"
print K+0
graph(n) = sprintf("K=%.2e",n)
plot file using 1:3 title graph(K)
しかし、エラーが発生します:数値式が予期されていた場所に非数値文字列が見つかりました
編集#2
file = "testPlot.txt"
K = "`head -1 file | awk '{print $6}'`"
K=K+0 #Cast K to a floating point number #this is line 9
graph(n) = sprintf("K=%.2e",n)
plot file using 1:3 title graph(K)
これにより、エラーが発生します-> head:file:そのようなファイルまたはディレクトリはありません "testPlot.gnu"、9行目:数値式が予期された場所に非数値文字列が見つかりました