How to get the value of a specific column in a specific line in any time of processing in gnuplot?

只愿长相守 提交于 2019-12-30 07:12:02

问题


I got a data file in the format like this:

# begin
16 1
15 2
14 3
13 4
12 5
11 6

Now I want to use gnuplot to draw a line through the points:

(1, (16/16))  (2, (16/15))  (3, (16/14)) ...  (6, (16/11)) 

As you see, the x axis is the range [1:6] and the Y axis corresponds the values obtained from the number in the first line at the first column(ie. 16 in this example) divided by the number in each line at the first column.

The problem is that I don't know how to get the value of the number at the first column in the first line (16), so that I could do something like

plot "datafile" using 2:(16/$1) with linespoints

I have done a lot of search about how to achieve that but with no luck. It seems that gnuplot doesn't provide some flexible ways to allow arbitrary data selection. Any ideas how to do that? Or maybe I just got stuck into a not so common problem?

Thanks for your help in advance.


回答1:


You can use the stats command to extract a single numerical value from your data file. The row is selected with the every option, the column with the using:

col = 1
row = 0
stats 'datafile' every ::row::row using col nooutput
value = STATS_min

plot "datafile" using 2:(value/$1) w lp

Note, that column numbering starts at 1, and row numbering at 0 (comment lines are skipped and aren't counted).



来源:https://stackoverflow.com/questions/26921329/how-to-get-the-value-of-a-specific-column-in-a-specific-line-in-any-time-of-proc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!