如何在gnuplot中处理的任何时间获取特定行中特定列的值? [英] How to get the value of a specific column in a specific line in any time of processing in gnuplot?

查看:71
本文介绍了如何在gnuplot中处理的任何时间获取特定行中特定列的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了这样的数据文件:

I got a data file in the format like this:

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

现在,我想使用gnuplot在各点之间画一条线:

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)) 

如您所见,x轴的范围是[1:6],Y轴对应的值是从第一列第一行的数字(即本例中的16)获得的值除以第一列中的每一行.

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.

问题是我不知道如何在第一行(16)的第一列中获取数字的值,因此我可以做类似

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

我已经做了很多关于如何实现这一目标的搜索,但是没有运气.gnuplot似乎没有提供一些灵活的方法来允许任意数据选择.任何想法如何做到这一点?或者也许我只是陷入了一个不太常见的问题?

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?

谢谢您的帮助.

推荐答案

您可以使用 stats 命令从数据文件中提取单个数值.使用 every 选项选择该行,使用 using 使用该列:

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

请注意,列编号从1开始,行编号从0开始(注释行被跳过并且不计算在内).

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

这篇关于如何在gnuplot中处理的任何时间获取特定行中特定列的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆