繁体   English   中英

gnuplot:标记/突出显示区域(linegraph的一部分)

[英]gnuplot: mark/highlight area (part of linegraph)

我的数据很简单,只是一个时间戳和这样的数字:

  • 2013-01-23 08:27:55 2801
  • 2013-01-23 08:33:13 2801
  • 2013-01-23 08:38:31 2660
  • 2013-01-23 08:43:49 2785
  • 2013-01-23 08:49:07 2785

我从另一个系统获取数据。 日期和时间之间的空格,以及“日期时间”和数字之间的制表者。

整个时间窗口是几个小时..几天。 这个整体时间窗口包含一个或多个有趣的部分(通常很少......几个小时),我想以某种方式标记或突出这些有趣的部分,以便更容易和更快地分析图形。

需要手动指定有趣的时间窗口,例如从2014-01-23 10:00:00到2013-01-24 12:00:00为2小时窗口。

将矩形绘制到线图的背景是一种可能性,并且改变线条颜色(或类似的东西)是另一种可能性。

如何通过手动/单独定义的时间戳完成此操作? 我能找到的最好的是用空行拆分数据,并使用类似的东西(来自http://www.gnuplotting.org/introduction/plotting-data/ ):

set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1.5   # --- blue
set style line 2 lc rgb '#dd181f' lt 1 lw 2 pt 5 ps 1.5   # --- red
plot 'plotting-data3.dat' index 0 with linespoints ls 1, '' index 1 with linespoints ls 2

但拆分数据有点艰巨(?); 我正在寻找优雅的gnuplot意味着实现目标。 如果那真的是最好的选择,那么也可以实现强大的分裂。

下面是绘图功能,效果很好,但我想标记/突出显示图表的选定部分。

-Paavo

function my_gnuplot {
  if [ $# -ne 3 -o -z "$1" -o -z "$2" -o -z "$3" ]
  then
    echo $0 $FUNCNAME Invalid parameters, exiting
    exit 3
  fi

  sid="$1" ; shift
  stime="$1" ; shift
  etime="$1" ; shift

  if [ $sid -gt 0 -a $sid -lt 10 ]
  then
    title=0$sid
  else
    title=$sid
  fi

  gnuplot <<- EOF
  reset
  set terminal png size 1800,900 enhanced font myfont.ttf 10

  set xdata time
  set timefmt "%Y-%m-%d %H:%M:%S"
  set format x "%Y-%m-%d %H:%M"

  set title "SID=$title from $stime to $etime"
  set grid

  set xrange [ "$stime" : "$etime" ]
  set yrange [ -2000 : 6000 ]
  set style data linespoints

  plot "sid_data_$sid.txt" using 1:9 notitle
        EOF
}

您可以使用矩形非常容易地填充空间:

set xdata time
set timefmt '%Y-%m-%d %H:%M:%S'
set object 1 rectangle from "2013-01-23 08:33:13",graph 0 to "2013-01-23 08:43:49",graph 1 fs solid fc rgb "red" behind
plot 'test.dat' u 1:3 w lines ls -1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM