本文介绍了gnuplot如何给列号动态绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gnuplot自动化创建小图的任务.而且我需要传递要绘制的数据文件中的列号

I am automating a task to create small graphs using gnuplot. And I need to pass the column number from the datafile that is to be plotted

pfile=system("echo $file")
colnum=system("echo $colnum")

plot pfile using 4:(column(colnum)) title "slot1"
                     ^^^^^^^^^^^^

colnum早先作为export colnum=2

突出显示的部分出现错误.我尝试通过系统命令使用导出/获取,但也没有用例如我尝试了4:colnum,遇到了类似的错误

I am getting error at the highlighted part. I tried using export/fetch by system command, but it didn't work eithere.g. I tried 4:colnum, got similar error

"./12.gnuplot.helper.pg", line 29: warning: Skipping data file with no valid points    
plot pfile using 4:(column(colnum)) title "slot1"   
                                                ^   
"./12.gnuplot.helper.pg", line 29: x range is invalid

推荐答案

似乎必须要做colnum=int(system("echo $colnum")),以便将变量colnum解释为整数而不是字符串

it seems that one has to do colnum=int(system("echo $colnum")) so that the variable colnum is interpreted as an integer and not a string

这篇关于gnuplot如何给列号动态绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 17:16