Gnuplot将任意秒列添加到日期/时间列

时间:2016-07-05 12:28:09

标签: date time gnuplot

我很难过。我有一个CSV文件,其列数为秒(文件开头为0秒),另一列为日期(mm/dd/yyyy hh:mm),其中包含数据的列。我正在绘制25 Hz数据(绞车张力,支付),因此hh:mm对于绘图来说不够精确,但我希望X轴仍然有mm/dd/yyyy hh:mm

我无法想到将秒列添加到日期/时间列而不包含x轴标签的优雅方法。有什么帮助吗?

以下是我的几行数据:

0.2340004,6/3/2016 20:09:09,384.0,0.0,3.4,1083.0,54.0,21.8,67.0,0.0,-0.1,,,,,,
0.2808005,6/3/2016 20:09:09,389.0,0.0,3.4,1110.0,54.0,21.9,67.0,0.0,-0.1,,,,,,
0.3276006,6/3/2016 20:09:10,397.0,0.0,3.4,1129.0,54.0,21.9,67.0,0.0,-0.1,,,,,,
0.3744007,6/3/2016 20:09:10,398.0,0.0,3.4,1149.0,54.0,21.9,67.0,0.0,-0.1,,,,,,

代码:

set datafile separator ","
set terminal wxt 0 
set grid  
set ls 1 lc rgb "blue" 
set ls 2 lc rgb "green"
set ls 3 lc rgb "red" 
set ytics nomirror
set y2tics nomirror
set xdata time
set timefmt "%m/%d/%Y %H:%M"
set format x "%m/%d/%y\n%H:%M"
set xtics rotate by -270
set key outside above left vert Right\
 noreverse enhanced autotitle box
set ylabel "Tension (lbs)"
set y2label "Wire Out (meters)"
set yrange [-300:2200] #change to set y range
set y2range [0:*] #change to set y range

plot  'WinchDAC-6-4-2016 07-38-56#3.csv' skip 11 using 2:9 w l t 'CTD Winch Tension' ls 1 axes x1y1,\
'' skip 11 using 2:11 w l t 'Wire Out' ls 2 axes x1y2,\
(x = 2000) axes x1y1 t 'SWL 0.032" (2,000 lbs)' ls 3 

谢谢!

1 个答案:

答案 0 :(得分:0)

您必须使用timecolumn函数来解析第二列中的时间数据(结果以内部参考日期后的秒数给出),然后添加第一列中的秒数:

set datafile separator ","
set xdata time
set timefmt "%m/%d/%Y %H:%M"
set format x "%m/%d/%y\n%H:%M"

file = 'WinchDAC-6-4-2016 07-38-56#3.csv' 
plot  file skip 11 using (timecolumn(2) + $1):9