简体   繁体   English

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

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

my data is quite simple, just a timestamp and a number like this: 我的数据很简单,只是一个时间戳和这样的数字:

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

I get the data from a another system. 我从另一个系统获取数据。 Space between date and time, and tabulator between "date time" and the number. 日期和时间之间的空格,以及“日期时间”和数字之间的制表者。

The whole time window is a few hours .. a couple of days. 整个时间窗口是几个小时..几天。 This overall time window contains one or more interesting parts (typically few..several hours), and I would like to mark or highlight these interesting parts somehow to make it easier and faster to analyse the graphs. 这个整体时间窗口包含一个或多个有趣的部分(通常很少......几个小时),我想以某种方式标记或突出这些有趣的部分,以便更容易和更快地分析图形。

Th einteresting time window would need to be specified manually, eg from 2014-01-23 10:00:00 to 2013-01-24 12:00:00 for 2 hour window. 需要手动指定有趣的时间窗口,例如从2014-01-23 10:00:00到2013-01-24 12:00:00为2小时窗口。

Drawing a rectancle to the background of the linegraph is one possibility, and changing the line color (or something similar) is another. 将矩形绘制到线图的背景是一种可能性,并且改变线条颜色(或类似的东西)是另一种可能性。

How can I do that from manually/separately defined time stamps? 如何通过手动/单独定义的时间戳完成此操作? The best I was able to find was splitting the data with empty lines, and use something like this (from http://www.gnuplotting.org/introduction/plotting-data/ ): 我能找到的最好的是用空行拆分数据,并使用类似的东西(来自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

But splitting the data is a bit arduous (?); 但拆分数据有点艰巨(?); I'm looking for elegant gnuplot means to achive the goal. 我正在寻找优雅的gnuplot意味着实现目标。 Robust splitting could be possible as well, if thats really the best alternative. 如果那真的是最好的选择,那么也可以实现强大的分裂。

Below is the plotting function, works well but I'd like to mark/highlight selected parts of the graph. 下面是绘图功能,效果很好,但我想标记/突出显示图表的选定部分。

-Paavo -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
}

You can use rectangles to fill the space pretty easily: 您可以使用矩形非常容易地填充空间:

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