GNUPLOT - 时间序列图的所有点 y 值均未定义

GNUPLOT - all points y value undefined for time series plot

我正在尝试使用 GNUPLOT 绘制时间序列数据,并且在 no_int1_date.dat 中有以下数据(只有一个片段):

1/25/20  0  1.0
1/26/20  1  0.9267715113341058
1/27/20  2  0.9015549457234168
1/28/20  3  0.9102921688940067
1/29/20  4  0.9434869898964108
1/30/20  5  0.9956757741755345

我希望将第 1 列绘制为 x 轴(日期),将第 3 列乘以乘数绘制为 y 轴(个人)。第 2 列包含索引或天数。我在源代码中使用以下几行:

set xdata time
set timefmt "%m/%d/%Y"
plot [100:370] "./data/no_int1_date.dat" u 1:(*0.0639) w line lw 2 lc "red" title 'Individuals requiring hospitalization', \
     [100:370] "./data/no_int1_date.dat" u 1:(*0.03) w line lw 2 lc "blue" title 'Individuals requiring intensive care'

命令错误 gnuplot -p hospital.gnuplot:

plot [100:370] "./data/no_int1_date.dat" u 1:(*0.0639) w line lw 2 lc "red" title 'Individuals requiring hospitalization',     [100:370] "./data/no_int1_date.dat" u 1:(*0.03) w line lw 2 lc "blue" title 'Individuals requiring intensive care',     1/0 lw 2 lc "red" dt 2 title "Hospital capacity",     1/0 lw 2 lc "blue" dt 2 title "Intensive care capacity" 
                                                                                                                                                                                                                                                                                                                                                                         ^
"./src/hospital.gnuplot", line 14: all points y value undefined!

然而,将源代码中的相同行修改为(注释掉指令并将列更改为索引或天数):

# set xdata time
# set timefmt "%m/%d/%Y"
plot [100:370] "./data/no_int1_date.dat" u 2:(*0.0639) w line lw 2 lc "red" title 'Individuals requiring hospitalization', \
     [100:370] "./data/no_int1_date.dat" u 2:(*0.03) w line lw 2 lc "blue" title 'Individuals requiring intensive care'

为什么我在尝试绘制具有日期的相同数据时出现错误?

Ubuntu 18.04,GNUPLOT 5.2 补丁级别 2

错误在于xrange的定义。您将 x 指定为格式为“month/day/year”的时间数据,但在 plot 命令中 xrange 被写为 [100:370],这与格式不匹配。我猜 gnuplot 正在将这些数字从 01.01.1970 或其他时间转换为秒数。 None 您的数据点位于此范围内,因此 gnuplot 无法绘制任何内容。

您可以将 xrange 指定为与​​您的时间数据相同的格式:

set xrange ["1/25/20":"1/30/20"]

plot ["1/25/20":"1/30/20"] "./data/no_int1_date.dat" ...

编辑:如果要绘制第 100 到 370 行,可以使用伪列 0 作为 x 轴:plot [100:370] "data.dat" using 0:3