GNUPLOT:如何停止;histeps“;从起点和终点处终止到零(y=0)?

GNUPLOT:如何停止;histeps“;从起点和终点处终止到零(y=0)?,gnuplot,Gnuplot,我使用以下脚本从文件“delete.dat”打印数据点 “delete.dat”文件是 但是开始和结束步骤都降到了零,这是我不想要的。尽管对于step和fsteps命令,步骤从第一个(最后一个)数据点开始(结束),但不会下降到零(y=0)。请您建议,如 HistEuth/Stult>(在步骤中间保持数据点),但不终止为零(如步骤< /强>或 f步骤< /强>)。我还附上照片 好吧,这就是hispteps、步骤和fsteps的定义。 然后,您必须创建自己的步骤。解决方案可以是: 代码:(改进版

我使用以下脚本从文件“delete.dat”打印数据点

“delete.dat”文件是

但是开始和结束步骤都降到了零,这是我不想要的。尽管对于stepfsteps命令,步骤从第一个(最后一个)数据点开始(结束),但不会下降到零(y=0)。请您建议,如<强> HistEuth/Stult>(在步骤中间保持数据点),但不终止为零(如<强>步骤< /强>或<强> f步骤< /强>)。我还附上照片


好吧,这就是
hispteps
步骤和
fsteps
的定义。 然后,您必须创建自己的步骤。解决方案可以是:

代码:(改进版)

####步骤与histeps类似,但不会降至零
重置会话
设置颜色序列经典

$Data如果您的数据点是等距的(如您提供的),也可以通过组合
fsteps
步数
并将x值移动点对点距离的一半来进行另一种破解:

plot "delete.dat" i 0 pt 7 ps 2 lc "black" not, \
'' i 1 pt 7 ps 2 lc "red" not, \
'' i 2 pt 7 ps 2 lc "green" not, \
'' u ($1-1.0):2 i 0 w steps lc "black", '' u ($1+1.0):2 i 0 w fsteps lc "black" not, \
'' u ($1+0.5):2 i 1 w steps lc "red", '' u ($1-0.5):2 i 1 w fsteps lc "red" not, \
'' u ($1-0.5):2 i 2 w steps lc "green", '' u ($1+0.5):2 i 2 w fsteps lc "green" not
这里的技巧是,
steps
fsteps
单独会错过最后一个或第一个点,并且直线将在空中结束,因此必须使用相同的打印样式将两者相互重叠

必须注意正确的符号:如果x为正,
steps
降档,
fsteps
升档;反之亦然,如果x为负


我的答案肯定没有theozh的答案那么“稳健”,但可能更容易理解。

这是黄金答案。
1 2
3 4
5 6
7 8
9 10


-1 5
-2 3
-3 4
-4 2
-5 6


5 1
6 2
7 3
8 4
9 5
10 4
11 3
12 12
### steps like histeps but not dropping to zero
reset session
set colorsequence classic

$Data <<EOD
1 2
3 4
5 6
7 8
9 10


-1 5
-2 3
-3 4
-4 2
-5 6


5 1
6 2
7 3
8 4
9 5
10 4
11 3
12 12
EOD

set table $myStep
    do for [i=0:2] {
        plot $Data u ($0==0?(x1=x2=$1):(x1=x2,x2=$1),(c=$0,x1+x2)/2.):2 index i w table
        plot $Data u 1:2 every ::c index i w table     # add last value
        plot '+' u ("") every ::::1 w table            # add two empty lines
    }
unset table

set key top left
plot for [i=0:2] $myStep u 1:2 index i w step lc i lw 3 notitle,\
     for [i=0:2] $Data u 1:2 index i w p pt 7 lc i notitle, \
### end of code
plot "delete.dat" i 0 pt 7 ps 2 lc "black" not, \
'' i 1 pt 7 ps 2 lc "red" not, \
'' i 2 pt 7 ps 2 lc "green" not, \
'' u ($1-1.0):2 i 0 w steps lc "black", '' u ($1+1.0):2 i 0 w fsteps lc "black" not, \
'' u ($1+0.5):2 i 1 w steps lc "red", '' u ($1-0.5):2 i 1 w fsteps lc "red" not, \
'' u ($1-0.5):2 i 2 w steps lc "green", '' u ($1+0.5):2 i 2 w fsteps lc "green" not