gnuplot在多列上的统计数据 [英] gnuplot computing stats over multiple columns

查看:194
本文介绍了gnuplot在多列上的统计数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的9列文件.我不会为每列计算某些统计数据,然后使用gnuplot对其进行绘制.

I have a simple 9 column file. I wan't to compute certain statistics for each column and then plot it (using gnuplot).

1).这是我如何计算除第一列以外的每一列的统计信息.

1) This is how I compute statistics for every column excluding the first one.

stats 'data' every ::2 name "stats"

2)在输出屏幕中,我看到该操作成功.请注意,列数/记录数为8

2) In the output screen I can see that the operation is successful. Note that the number of columns/records is 8

* FILE: 
  Records:      8
  Out of range: 0
  Invalid:      0
  Blank:        0
  Data Blocks:  1

* COLUMNS:
  Mean:          6.5000       491742.6625
  Std Dev:       2.2913          703.4865
  Sum:          52.0000       3.93394e+06
  Sum Sq.:     380.0000       1.93449e+12

  Minimum:       3.0000 [0]   490312.0000 [2]
  Maximum:      10.0000 [7]   492643.5000 [7]
  Quartile:      4.5000       491329.5000
  Median:        6.5000       491911.1500
  Quartile:      8.5000       492252.2500

  Linear Model: y = 121.8 x + 4.91e+05
  Correlation:  r = 0.3966
  Sum xy:       2.558e+07

3)现在,我可以通过添加_x和_y来访问前两列的统计信息

3) Now I can access statistics on the first 2 columns by appending _x and _y like this

print stats_median_x
print stats_median_y

我的问题是:

  • 如何获取其余6列的统计信息(比如中位数)?
  • 我如何绘制一条相对于某个X轴的所有中位数的直线?

我知道我可以简单地添加一个python脚本来预先计算所有这些内容,但是如果有使用gnuplot本身的简便方法,我宁愿避免使用它.

I know that I can simply add a python script to pre-compute all this, but I would prefer to avoid it if there is an easy way to do it using gnuplot itself.

谢谢!

推荐答案

简短答案

  • 如何访问另一列的统计信息?"
    使用stats 'data'using n,您将访问第n th 列...
  • 例如,如何绘制所有中位数?"
    例如set printdo for循环可以创建可用于绘图的数据文件.
  • "How can I access statistics of the other column?"
    with stats 'data'using n you will access to the nth column...
  • "How can I plot for example all medians?"
    e.g. a set print and a do for cycle can create a data-file that you can use for the plot.

有效的解决方案

    set print "StatDat.dat" 
    do for [i=2:9] { # Here you will use i for the column.
      stats  'data.dat' u i nooutput ; 
      print i, STATS_median, STATS_mean , STATS_stddev # ...
    } 
    set print
    plot "StatDat.dat" us 1:2 # or whatever column you want...

有关此词的更多信息
寻求帮助来使用help stats gnuplot本身,就有可能阅读很多有趣的东西:-).

Some words more about it
Asking help to gnuplot itself with help stats it's possible to read a lot of interesting things :-).

语法:
统计数据'文件名' [使用N [:M]] [名称'前缀'] [[无]输出]]
此命令准备文件一两列中数据的统计摘要. 使用说明符的解释方式与绘图命令相同.请参见plot有关indexeveryusing指令的详细信息.

Syntax:
stats 'filename' [using N[:M]] [name 'prefix'] [[no]output]]
This command prepares a statistical summary of the data in one or two columns of a file. The using specifier is interpreted in the same way as for plot commands. See plot for details on the index, every, and using directives.

  • 从第一个突出显示的句子中我们可以理解,它每次都会为一列或最多两列准备统计信息(很遗憾,让我们在以后看到...).
  • 从第二个突出显示的句子中可以看出,它将遵循plot命令的相同语法:
    因此stats 'data'using 3将为您提供x
    中第三列的统计信息 和x,y ...
  • 中第4位和第5位的stats 'data' using 4:5

    • From the first highlighted sentence we can understand that it prepares statistics for one or maximum two column each time (It's a pity let's see in future...).
    • From the second highlighted sentence it's possible to read that it will follow the same syntax of the plot command:
      so stats 'data'using 3 will give you the statistic of the 3rd column in x
      and stats 'data' using 4:5 of the 4th and 5th in x,y...
    • 关于您的解释的提示

      1. 你说的

      1. You said

      这是我如何计算除第一列以外的每一列的统计信息.
      stats 'data' every ::2 name "stats"

      This is how I compute statistics for every column excluding the first one.
      stats 'data' every ::2 name "stats"

      这不是前两列(不包括前两行)的统计信息,实际上,它们的计数器从0开始而不是从1开始.

      Not really this is the statistic for the first two column excluding the first two lines, indeed their counter starts from 0 and not from 1.

      由于上述假设/解释,当我们阅读

      As consequence of the above assumption/interpretation, when we read

      记录:8

      Records: 8

      这表示在8处计算的行;您的文件有10行(可用),您指定every ::2行,并且跳过了前两行,因此有8条记录对统计有用.
      的确如此,我们可以更好地理解在help stats中什么时候说了

      it means that the lines computed where 8; your file had 10 (usable) lines, you specify every ::2 and you skip the first two, thus you have 8 records useful for the statistic.
      Indeed so we can better understand when in help stats it is said

      STATS_records           # total number of in-range data records
      

      暗含用于计算此统计信息" .

      在gnuplot 4.6补丁程序级别4上测试
      使用gnuplot版本5.0补丁程序级别1

      这篇关于gnuplot在多列上的统计数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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