【问题标题】:Gnuplot add arbitrary seconds column to date/time columnGnuplot 将任意秒列添加到日期/时间列
【发布时间】:2016-07-05 12:28:08
【问题描述】:

我被难住了。我有一个 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 

谢谢!

【问题讨论】:

    标签: date time gnuplot


    【解决方案1】:

    您必须使用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
    

    【讨论】:

      猜你喜欢
      • 2023-01-19
      • 1970-01-01
      • 2015-10-13
      • 1970-01-01
      • 2020-12-01
      • 2017-11-17
      • 2016-07-10
      • 2018-11-15
      • 1970-01-01
      相关资源
      最近更新 更多