我有两个具有不同时间格式的数据:
file1(%Y%j%H%M%S vel):
2011 170 0 0 0 0.017042
2011 170 0 30 0 0.002124
2011 170 1 0 0 0.061001
2011 170 1 30 0 0.096256
2011 170 2 0 0 0.073920
2011 170 2 30 0 0.048899
2011 170 3 0 0 0.039534
2011 170 3 30 0 0.044790
2011 170 4 0 0 0.052662
2011 170 4 30 0 0.063144
等...
file2(%Y%m%d%H%M潮):
2011 06 19 00 00 2.1950
2011 06 19 00 05 2.2650
2011 06 19 00 10 2.3290
2011 06 19 00 15 2.4030
2011 06 19 00 20 2.4730
2011 06 19 00 25 2.5480
2011 06 19 00 30 2.6220
2011 06 19 00 35 2.6890
2011 06 19 00 40 2.7690
2011 06 19 00 45 2.8460
2011 06 19 00 50 2.8970
2011 06 19 00 55 2.9690
2011 06 19 01 00 3.0610
2011 06 19 01 05 3.1370
2011 06 19 01 10 3.2030
2011 06 19 01 15 3.2670
等...
是否可以在同一张图中绘制这些数据?如果是这样,该怎么办?
我所做的是:
设置xdata时间
设置timefmt“%Y%j%H%M%S”
设置xtics“ 2011 170 0 0 0”,43200,“ 2011 172 0 0 0”
设置xrange [“ 2011 170 0 0 0”:“ 2011 172 0 0 0“]
设置xtics格式”%j“
图” ./file1“ u 1:6 w行ls 3 lc rgb”暗红色“ notitle,\
” ./file2“ u 1:6 w行ls 3 lc rgb“黑色”无标题轴x1y2
结果似乎不正确。
任何帮助将不胜感激。
谢谢
您必须手动解析第二个文件的时间。在gnuplot 5.0中,这非常舒适,因为您可以简单地指定timecolumn
时间格式作为第二选择。然后,它使用这种格式,而不是使用以下格式set timefmt
:
set xdata time
set timefmt "%Y %j %H %M %S"
set xtics "2011 170 0 0 0",43200, "2011 172 0 0 0"
set xrange ["2011 170 0 0 0":"2011 172 0 0 0"]
set xtics format "%j"
set y2tics
set ytics nomirror
plot "./file1.txt" u 1:6 w lines ls 3 lc rgb "dark-red" notitle, \
"./file2.txt" u (timecolumn(1, "%Y %m %d %H %M")):6 w lines ls 3 lc rgb "black" notitle axes x1y2
在早期的gnuplot版本中,您必须首先构造一个包含所有时间信息的字符串,然后使用以下命令解析该字符串strptime
:
set xdata time
set timefmt "%Y %j %H %M %S"
set xtics "2011 170 0 0 0",43200, "2011 172 0 0 0"
set xrange ["2011 170 0 0 0":"2011 172 0 0 0"]
set xtics format "%j"
set y2tics
set ytics nomirror
mytimecolumn(c, fmt) = strptime(fmt, sprintf('%s %s %s %s %s', strcol(c), strcol(c+1), strcol(c+2), strcol(c+3), strcol(c+4)))
plot "./file1.txt" u 1:6 w lines ls 3 lc rgb "dark-red" notitle, \
"./file2.txt" u (mytimecolumn(1, "%Y %m %d %H %M")):6 w lines ls 3 lc rgb "black" notitle axes x1y2
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句