使用gnuplot在2D图上添加水平线 [英] Adding Horizontal lines on 2D plot with gnuplot
本文介绍了使用gnuplot在2D图上添加水平线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码段从多个数据文件(snapshot_XXXX.dat)创建2D图
I am creating a 2D plot from several data files (snapshot_XXXX.dat) using the following snippet
set terminal pngcairo
n=1000 # Number of snapshots
load 'color.pal'
# cbrange[-6:-2]
unset key
set style fill solid
set ylabel "Snapshot/Time"
# set yrange [0.5:n+0.5]
# set ytics 1 # manage it well in order to avoid black lines at the
borders
set xrange[0:2021]
set yrange[0:8]
# This functions gives the name of the snapshot file
snapshot(i) = sprintf("snapshot_%04d.dat", i)
plot for [i=1:n] './snapshots/'. snapshot(n+1-i) using 1:2:3 with boxes
linecolor palette
结果为:图片
快照看起来像
snapshot_0001.dat snapshot_0002.dat snapshot_0003.dat
1 1.0 0.0 1 1.0 0.0 1 1.0 0.0
2 1.5 0.0 2 1.5 0.0 2 1.5 0.0
3 2.0 0.5 3 2.0 0.7 3 2.0 0.7
4 2.5 1.0 4 2.5 1.5 4 2.5 1.5
5 3.0 0.5 5 3.0 0.7 5 3.0 1.1
6 3.5 0.0 6 3.5 0.0 6 3.5 0.7
7 4.0 0.0 7 4.0 0.0 7 4.0 0.0
8 4.5 0.0 8 4.5 0.0 8 4.5 0.0
9 5.0 0.0 9 5.0 0.0 9 5.0 0.0
这些当然是假数据,因为原始文件太重而无法添加到此帖子中.我想在特定时间添加水平线(标为SnapShot/TIME的轴).
Of course these are fake data since the original files are too heavy to add to this post. I would like to add horizontal lines at particular times (axis labelled SnapShot/TIME).
有人可以帮助我解决这个问题吗?
Is someone can help me with this issue?
推荐答案
这解决了我的问题
set arrow from 0.,5.6 to 2021., 5.6 nohead front lc rgb "black" lw 4 dashtype "-"
非常感谢Christoph
Many thanks Christoph
这篇关于使用gnuplot在2D图上添加水平线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文