2017-04-10 79 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