如何让 gnuplot 忽略 stats 命令中的时间列

问题描述 投票:0回答:2

我有一个数据集,如下所示:

23.10.2019T09:07:20 0.158
23.10.2019T09:15:51 0.123
23.10.2019T09:18:34 0.140
23.10.2019T09:30:16 0.106
23.10.2019T09:30:59 0.123
23.10.2019T09:31:14 0.117
23.10.2019T09:32:49 0.155
23.10.2019T09:34:36 0.148
23.10.2019T09:36:51 0.132
23.10.2019T09:37:21 0.108

我想仅使用第二列来计算统计数据,但我没有运气。

gnuplot> stats '~/work/logs/betd_log_SN0425/1066_duration.txt' u 2
         Stats command not available in timedata mode

gnuplot> stats '~/work/logs/betd_log_SN0425/1066_duration.txt' u 2:2
         Stats command not available in timedata mode

gnuplot> stats '~/work/logs/betd_log_SN0425/1066_duration.txt' u (1.0):2
         Stats command not available in timedata mode

gnuplot> stats '~/work/logs/betd_log_SN0425/1066_duration.txt' u 2:(1.0)
         Stats command not available in timedata mode
gnuplot
2个回答
1
投票

统计数据不采用时间格式。您必须通过

strptime(...)
将其转换为 01.01.1970 的秒数。然后您可能需要通过
strftime(...)
将其重新转换为可读日期。检查
help strptime
help strftime
。 您到底想提取什么?最小值、最大值……外推法……? 尝试以下操作。

代码:

### stats with datetime
reset session

$Data <<EOD
23.10.2019T09:07:20 0.158
23.10.2019T09:15:51 0.123
23.10.2019T09:18:34 0.140
23.10.2019T09:30:16 0.106
23.10.2019T09:30:59 0.123
23.10.2019T09:31:14 0.117
23.10.2019T09:32:49 0.155
23.10.2019T09:34:36 0.148
23.10.2019T09:36:51 0.132
23.10.2019T09:37:21 0.108
EOD

myTimeFmt = "%d.%m.%YT%H:%M:%S"

stats $Data u (strptime(myTimeFmt,strcol(1))):2
### end of code

结果:

    * FILE: 
  Records:           10
  Out of range:       0
  Invalid:            0
  Column headers:     0
  Blank:              0
  Data Blocks:        1

* COLUMNS:
  Mean:          1.57182e+09             0.1310
  Std Dev:          575.1860             0.0178
  Sample StdDev:    606.2992             0.0187
  Skewness:          -0.9459             0.1355
  Kurtosis:           2.5313             1.6792
  Avg Dev:          492.0600             0.0156
  Sum:           1.57182e+10             1.3100
  Sum Sq.:       2.47063e+19             0.1748

  Mean Err.:        181.8898             0.0056
  Std Dev Err.:     128.6155             0.0040
  Skewness Err.:      0.7746             0.7746
  Kurtosis Err.:      1.5492             1.5492

  Minimum:       1.57182e+09 [ 0]        0.1060 [ 3]
  Maximum:       1.57182e+09 [ 9]        0.1580 [ 0]
  Quartile:      1.57182e+09             0.1170
  Median:        1.57182e+09             0.1275
  Quartile:      1.57182e+09             0.1480

  Linear Model:       y = -1.178e-05 x + 1.852e+04
  Slope:              -1.178e-05 +- 1.009e-05
  Intercept:          1.852e+04 +- 1.586e+04
  Correlation:        r = -0.3816
  Sum xy:             2.059e+09

1
投票

正如 theozh 指出的那样,我之前曾将

set xdata time
用于
plot
命令。所以需要使用
set xdata
重置
xdata
模式。

© www.soinside.com 2019 - 2024. All rights reserved.