簡體   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