我的数据很简单,只是一个时间戳和这样的数字:
我从另一个系统获取数据。日期和时间之间的空格,以及“日期时间”和数字之间的制表符。
整个时间窗口是几个小时..几天。这个整体时间窗口包含一个或多个有趣的部分(通常很少......几个小时),我想以某种方式标记或突出显示这些有趣的部分,以便更容易,更快地分析图形。
需要手动指定有趣的时间窗口,例如从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
}
答案 0 :(得分:2)
您可以使用矩形来轻松填充空间:
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