gnuplot中x轴的日期和时间格式

时间:2016-09-24 20:16:51

标签: time gnuplot

我有一个csv文件,看起来像:

  

1,Fri Jun 27 2014年2月23日22:22

     

...

     

3500,2014年6月28日星期六09:21:55

我想将第1列设为y,将第2列设为x:

set datafile separator ","
set xdata time
set timefmt "%a %b %d %T %Y"
set format x "%d-%b\n%H:%M"
plot "file.csv" u 2:1

对于每一行我都会收到错误:

warning: Bad time format in string
warning: Bad abbreviated month name
warning: Skipping data file with no valid points

最后x范围无效

我真的不知道发生了什么。我的时间格式很好看。对? 谢谢!

1 个答案:

答案 0 :(得分:3)

Gnuplot不支持%a中的%Ttimefmt说明符(尽管如此,它们可以在set format x中使用) - 请参阅p。 documentation中的168。

虽然%T可以直接替换为%H:%M:%S,但%a似乎有点问题。解决方法是预处理文件以消除第二列中的日期名称,例如。

set xdata time
set timefmt "%b %d %H:%M:%S %Y"
set format x "%d-%b\n%H:%M"
plot "<(gawk -F, '{print $1, substr($2, 5)}' file.csv)" u 2:1

请注意,由于文件是由gawk预处理的,因此此处不再需要set datafile separator ","命令。

相关问题