2017-04-10 33 views
1

處理我有以下rule_times.dat文件:gnuplot的標籤不按功能

0 min 4246 
0.5 min 26543 
1.5 max 38339128 
2 max 7293253 
3 avg 103698.380554429 
3.5 avg 43305.9820981295 

及以下gnuplot腳本:

reset 
set style line 1 lc rgb "#c42f27" 
set style line 2 lc rgb "#2f27c4" 
set terminal png 
set boxwidth 0.5 
set style fill solid 

set xtics("min" 0.25, "max" 1.75, "avg" 3.25) 

set ylabel "log(time for 1000 evaluations)" 
set ytics 10000 
set yrange [0:25] 

to_us(x)=floor(x/1000) 
set title "Evaluation times for direct rule evaluation" 

plot "rule_times.dat" using 1:(log($3)):(to_us($3)) with labels offset character 0, character 1 tc rgb "black" title "", \ 
    "rule_times.dat" every 2 using 1:(log($3)) with boxes ls 1 title "log(eval)", \ 
    "rule_times.dat" every 2::1 using 1:(log($3)) with boxes ls 2 title "log(lookup)" 

和我得到的輸出如下: plot

我希望數字除以1000,並舍入/鋪設/任何,以便條上的標籤很小呃數字,但功能似乎不適用!我錯過了什麼?

回答

2

表達式floor(x/1000)返回必須轉換爲字符串的數字。一些想法:

的結果追加到一個空字符串隱式轉換:

to_us(x)="".floor(x/1000) 

顯式轉換可能具有更大的靈活性:

to_us(x)=sprintf("%6.2f", (x/1000)) 
+0

參見http://stackoverflow.com/a/ 22832519/2604213和關於sourceforge的鏈接討論。 – Christoph