4

我想用 x 数据绘制数据作为时间值。csv 文件如下所示

"","12/09/29","00:19:43","  1787","    12","12"
"","12/09/29","00:19:48","  1787","    12","12"
"","12/09/29","00:19:53","  1785","    13","12"
"","12/09/29","00:19:58","  1785","    12","12"

这里的问题是双引号的使用。我试过这个

set timefmt '"%y/%m/%d","%H:%M:%S"'
set datafile separator ","
plot 'myFile.csv' using 2:3:4 with lines

但它不识别时间格式。

如何使用双引号和逗号分隔符从两个分隔列中识别时间值?

谢谢您的帮助。

托马斯

4

1 回答 1

2

如果引号是问题所在,并且您在启用管道的 posix 系统上,则可以轻松删除它们:

plot '< sed -e s/\"//g test.dat' using 2:4:5

请注意,using规范也发生了变化(2:4:5而不是2:3:4),因为您的时间格式需要2 列


请注意,我认为引号没有问题:

set datafile sep ','
set xdata time
set timefmt '%y/%m/%d,%H:%M:%S'  #no quotes in timefmt -- Gnuplot removes them when parsing the datafile.
plot 'test.dat' using 2:4:5 with lines

为我工作。

所以我真的认为问题在于您使用规范指向第三列(包含时间信息)而不是第四列。最后,您可以使用using 2:4-- 您实际上从未将第 5 列用于此处的任何内容来制作相同的图。

于 2012-11-15T14:09:09.630 回答