【问题标题】:Gnuplot misreads time dataGnuplot 误读时间数据
【发布时间】:2017-04-03 09:03:07
【问题描述】:

我似乎无法让 gnuplot 正确绘制我的时间数据。 (我使用的是 4.6 版,补丁级别 3。)

对于 MWE(好吧,不工作...),输入文件

reset

set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M:%S"

plot '-' using ($1):($2) with lines lw 3
15:36:12  1.0
15:43:17  3.0
16:12:02  2.0
e

产生以下输出:

显然,gnuplot 将小时解释为秒并忽略其余部分。我尝试了一堆其他格式字符串(也是单引号/双引号),但 gnuplot 似乎忽略了除第一个数字之外的所有内容。

我的格式有问题吗,或者这是一个错误,还是其他什么?

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    使用$1,您可以明确选择第一列的 numerical 值,这会绕过任何 gnuplot 自动机制来适当地解释列值(在您的情况下为时间值)。只需使用using 1:2:

    reset
    set xdata time
    set timefmt "%H:%M:%S"
    set format x "%H:%M:%S"
    
    plot '-' using 1:2 with lines lw 3
    15:36:12  1.0
    15:43:17  3.0
    16:12:02  2.0
    e
    

    仅在使用相应列中的实际数值进行计算时使用语法$1$1column(1) 的快捷方式,gnuplot 也知道 stringcolumn(1)timecolumn(1) 用于其他用途。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-24
      相关资源
      最近更新 更多