gnuplot how to give column number to plot dynamically?

前端 未结 3 1423
清酒与你
清酒与你 2021-01-15 15:33

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         


        
3条回答
  •  抹茶落季
    2021-01-15 16:06

    This is an alternative to @EWCZ's answer. Any variable initialized using the system command is treated as a string: in your case, colnum="2" (with quotes). You can transform it to an integer by adding zero:

    # first option
    plot pfile using 4:(column(colnum+0))
    
    # second option
    colnum = system("echo $colnum") + 0
    plot pfile using 4:(column(colnum))
    

    As a side note, your task could be more flexible (easier to automate) by using @Christoph's answer; better if you have gnuplot 5.0 because you can pass arguments to a gnuplot script directly

提交回复
热议问题