Awk在gnuplot命令的第二部分或子图中不工作

Awk在gnuplot命令的第二部分或子图中不工作,awk,gnuplot,average,Awk,Gnuplot,Average,通过gnuplot,我试图在图形上打印一条平均线,但如果我在第二部分中使用awk命令或像这样的第二个子图命令,它就不起作用了 plot "iops.1.log" using ($1/1000):2 with lines title "job 1",\ "<awk '{sum += $2} END {print sum/NR}' iops.1.log" with lines title "avg iops" 上面的行仅使用第二个子批次中的一个值(4590)打印图形中的运行平均线

通过gnuplot,我试图在图形上打印一条平均线,但如果我在第二部分中使用
awk
命令或像这样的第二个子图命令,它就不起作用了

plot "iops.1.log" using ($1/1000):2 with lines title "job 1",\
     "<awk '{sum += $2} END {print sum/NR}' iops.1.log" with lines title "avg iops"
上面的行仅使用第二个子批次中的一个值(4590)打印图形中的运行平均线


到底发生了什么,为什么不能工作

这可能是一个bug,但幸运的是,您可以在不需要awk的情况下计算gnuplot中的平均y值:

stats "iops.1.log" nooutput
ave=STATS_sum_y/STATS_records
plot "iops.1.log" using ($1/1000):2 with lines title "job 1",\
 ave with lines title "avg iops"

使用
plot“绘图时,结构
stats "iops.1.log" nooutput
ave=STATS_sum_y/STATS_records
plot "iops.1.log" using ($1/1000):2 with lines title "job 1",\
 ave with lines title "avg iops"
avg = system("<awk '{sum += $2} END {print sum/NR}' iops.1.log")
plot "iops.1.log" using ($1/1000):2 with lines title "job 1",\
     int(avg) with lines title "avg iops"
plot "iops.1.log" using ($1/1000):2 with lines title "job 1",\
    `awk '{sum += $2} END {print sum/NR}' iops.1.log` with lines title "avg iops"