代码之家  ›  专栏  ›  技术社区  ›  theozh

扩展数据时间中秒数为负的意外行为

  •  0
  • theozh  · 技术社区  · 5 年前

    当用扩展数据时间绘制时,有谁能解释gnuplot在负秒数下的奇怪行为?我是说中间的曲折路线。这是虫子还是我遗漏了什么?(gnuplot 5.2.6)

    代码:

    ### strange behaviour with negative fractions of seconds in xdata time
    reset session
    
    set table $Data
        plot '+' u 1:($1**2) w table
    unset table
    
    set multiplot layout 3,1
        plot $Data u 1:2 w lp pt 7 lc rgb "web-green"
    
        set xdata time
        set timefmt "%s"
        set format x "%H:%M:%S"
        plot $Data u 1:2 w lp pt 7 lc rgb "red"
    
        set format x "%H:%M"
        plot $Data u ($1*60):2 w lp pt 7 lc rgb "web-blue"
    
    unset multiplot
    ### end of code
    

    结果:

    enter image description here

    0 回复  |  直到 5 年前
        1
  •  3
  •   Ethan    5 年前

    你把事情搞得太复杂了。你的数据是纯秒级的。不需要调用“set xdata time”或“set timefmt”变量,因为输入只是一个浮点数。在输出时,根据您是希望X轴标记为绝对时间(午夜换行)还是相对时间(+/-interval),设置XTIC格式。

    ### absolute vs relative time formats
    set table $Data
        plot '+' u 1:($1**2) w table
    unset table
    
    set multiplot layout 3,1
        plot $Data u 1:2 w lp pt 7 lc rgb "web-green"
    
        set xtics time format "%tH:%tM:%tS" # relative time
        plot $Data u 1:2 w lp pt 7 lc rgb "red"
    
        set xtics time format "%H:%M:%S"    # absolute time
        plot $Data u 1:2 w lp pt 7 lc rgb "blue"
    unset multiplot
    ### end of code
    

    enter image description here

    但不,对不起,我不能解释为什么你原来的情节是曲折的。