gnuplot - 在具有不同 timefmt 的 gnuplot 中绘制两个文件

标签 gnuplot datetime-format

我需要使用 gnuplot 在同一个图中绘制两个数据文件。第一个数据文件是这样的:

2015-02-10 10.1
2015-02-15 12.1
2015-02-20 16.1
2015-02-25 14.1
...

第二个数据文件就像
2015-02-10-10:00 12.5
2015-02-10-15:00 21.4
2015-02-15-12:30 08.3
2015-02-15-22:00 09.3
2015-02-20-08:15 12.8
2015-02-20-17:32 16.7
2015-02-25-07:20 14.0
2015-02-25-21:39 14.5
..

解析第一个数据文件,timefmt应设置为 "%Y-%m-%d"对于第二个文件,它将是 "%Y-%m-%d-%H:%M" .但是,由于两个数据文件应该一起绘制,我该如何定义 timefmt适本地?

最佳答案

对于 4.6 版及更早版本,您必须使用 strptime“手动”解析日期时间字符串。 :

set xdata time
plot 'file1.dat' using (strptime('%Y.%m.%d', strcol(1))):2,\
     'file2.dat' using (strptime('%Y.%m.%d-%H:%M', strcol(1))):2

使用 gnuplot 版本 5,您可以直接为 timecolumn 提供时间格式。函数,以便您可以使用任意数量的格式:
set xdata time
plot 'file1.dat' using (timecolumn(1, '%Y.%m.%.d')):2,\
     'file2.dat' using (timecolumn(1, '%Y.%m.%d-%H:%M')):2

在您的情况下,两种变体之间的差异很小,但是当日期时间跨数据文件中的多列时,后一种变体要舒服得多,因为 timecolumn自动处理多列。

关于gnuplot - 在具有不同 timefmt 的 gnuplot 中绘制两个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31008007/

相关文章:

c++ - 来自 std::vector<double> 的未格式化流输入

C# DateTime ParseExact 异常

gnuplot - 如何在 GnuPlot 中使绘图变大

Gnuplot 烛台和箱宽

使用 xdate 绘制直方图时的 Gnuplot 错误

android - android中两种日期时间格式之间的区别?

datetime - ISO-8601 是否允许使用时区缩写 UTC 而不是 Z 作为时区?

javascript - Date 对象最兼容的 javascript 时间格式是什么

java - 如何设置字符串(HH :mm) to UTC time with current date and convert it to local time

gnuplot - 语法错误 : several plots, 其中之一是带有星号(星号)模式的 for 循环