如何使用GnuPlot绘制CSV文件日期和时间的时间序列图表存储在双引号的单独列中?

我想用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

但它不承认时间格式.

如何通过双引号和逗号分隔符识别两个分隔列的时间值?

谢谢您的帮助.

托马斯

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

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

请注意,使用规范也已更改(2:4:5而不是2:3:4),因为您的timeformat需要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

适合我.

所以我真的认为问题是你的使用规范指向第三列(包含时间信息)而不是第四列.最后,您可以使用2:4制作相同的图 – 您实际上从未在这里使用第5列.

点赞