GNUPLOT:表达无效?

时间:2013-07-25 21:13:16

标签: linux bash shell gnuplot

我有一个简单的gnuplot脚本,可以绘制一堆图表。当我运行它时,它会出现以下错误:

编辑:根据建议

,我大大减少了代码的长度
    ;
    set xrange [pe_cnt:range_high];
    set xtics xticks;
    set xtics add (pe_cnt) 
                                                                                 ^
line 26: invalid expression 

我花了很多时间试图解决这个问题。如果有人能帮助我,我真的很感激。这是我的代码:

range_high="`awk '{for(i=1;i<=NF;i++) if ($i=="--stop") print $(i+1)}' temp_info`"
xticks="`awk '{for(i=1;i<=NF;i++) if ($i=="--xticks") print $(i+1)}' temp_info`"
pe_cnt = "`awk '{for(i=1;i<=NF;i++) if ($i=="--pe_cnt") print $(i+1)}' temp_info`"
rd_cnt = "`awk '{for(i=1;i<=NF;i++) if ($i=="--rd_cnt") print $(i+1)}' temp_info`"


##################################################################################################
# Gnuplot script file for plotting Micron >= 1,16,32,64 WAFL single read last read


set autoscale    
set grid         
set title "Usable Flash Blocks vs PE cycles"

set xlabel "PE Cycles  "
set ylabel "% Usable Flash Blocks "
set y2label "% WAFL Blocks"

if (pe_cnt == range_high) {
    set xrange [pe_cnt-1:range_high]
    set xtics xticks
    set xtics add (pe_cnt-1) }
else { 
    set xrange [pe_cnt:range_high]
    set xtics xticks
    set xtics add (pe_cnt) }

set yrange [-10:140]
set y2range [-10:140]

set ytics 10
set y2tics 10

set term postscript color solid
set output 'Micron_srd.ps'

#set datafile separator ' '

set key top left
plot "Micron_all"      using (($1+1)*pe_cnt):(((256-$31)*100)/256)  smooth bezier  title '(>= 1 Bad WAFL)'      axis x1y1 with lines, \
     "Micron_all"      using (($1+1)*pe_cnt):(((256-$33)*100)/256)  smooth bezier  title '(>= 16 Bad WAFL)'      axis x1y1 with lines, \
     "Micron_all"      using (($1+1)*pe_cnt):(((256-$34)*100)/256)  smooth bezier  title '(>= 32 Bad WAFL)'      axis x1y1 with lines, \
     "Micron_all"      using (($1+1)*pe_cnt):(((256-$36)*100)/256)  smooth bezier  title '(>= 64 Bad WAFL)'      axis x1y1 with lines, \
     "Micron_all"      using (($1+1)*pe_cnt):(($14*400)/$5)  smooth bezier  title '(Uncorrectable WAFL)'      axis x1y2 with lines, \
     "Micron_all"      using (($1+1)*pe_cnt):(($70*100)/$5)  smooth bezier  title '(Correctable WAFL)'      axis x1y2 with lines

2 个答案:

答案 0 :(得分:1)

问题可能是pe_cnt不是数字,但是你的测试用例不是自包含的(它从某个文件读取这个值),所以很难具体。

这是一个简短的自包含示例,它使用相同的代码演示相同的错误消息:

pe_cnt = "kittens"
set xtics add (pe_cnt)

答案 1 :(得分:1)

使用

set xtics add (real(pe_cnt))

我猜,xtics add不会自动将字符串转换为数字,因为当首先遇到字符串时,它还允许使用不同的语法。 演员如下:

set xtics add (pe_cnt pe_cnt)