GNUPLOT绘制不在边界限制内的步骤图

GNUPLOT绘制不在边界限制内的步骤图,gnuplot,Gnuplot,绘制步骤图总是导致边界外结果。 如何解决这个问题?有什么想法吗?谢谢 MWE是: reset;set term png small size 500,500;set output 'test.png'; set title 'First step is always drawn out of chart borders ?!?'; unset y2tics;set y2range [0:40];set y2tics 10;set yrange [0:40];set ytics 10 mirror

绘制步骤图总是导致边界外结果。
如何解决这个问题?有什么想法吗?谢谢

MWE是:

reset;set term png small size 500,500;set output 'test.png';
set title 'First step is always drawn out of chart borders ?!?';
unset y2tics;set y2range [0:40];set y2tics 10;set yrange [0:40];set ytics 10 mirror;
set style fill solid 1.00 border;
plot 'test.data' using 1:2  notitle with fillsteps lc rgb 'light-goldenrod', \
'' using 1:3 notitle with fillsteps lc rgb 'gray40', \
'' using 1:4 notitle with fillsteps lc rgb 'web-green', \
'' using 1:5 notitle with fillsteps lc rgb 'light-green';
结果是:

使用的软件是:


GNUPLOT版本5.2 patchlevel 8

好的,现在我明白你的意思了。看起来像一个小错误(或我们有限的理解)。 我不能马上说出原因,但你可以避免 通过在开头添加一行,其中包含第一个x值和所有y值
0
。 如果您不想手动执行此操作,那么可以使用gnuplot自动执行此操作。 但我希望有一个更简单的解决办法

代码:

### plot with fillsteps
reset session

$Data <<EOD
1    0   0   0   0
1   50  35  30   5
2   55  30  20   5
17  51  44  30  12
20   1   1   1   1
EOD

unset y2tics;set y2range [0:40]
set y2tics 10
set yrange [0:40]
set ytics 10 mirror
set style fill solid 1.00 border
unset key

plot $Data u 1:2 w fillsteps lc 'light-goldenrod', \
        '' u 1:3 w fillsteps lc 'gray40', \
        '' u 1:4 w fillsteps lc 'web-green', \
        '' u 1:5 w fillsteps lc 'light-green'
### end of code
代码:(结果同上)

#https://stackoverflow.com/a/67151340/7295599
###用填充曲线绘图
重置会话
FileToDatablock(f,d)=GPVAL_SYSNAME[1:7]eq“Windows”\

sprintf(“echo-e“150 35 30 5/n2 55 30 20 5/n17 51 44 30 12/n20 1 1”>test.data
或任何您喜欢的第二列值大于40(即边界值)的数据。如果这是您要绘制的数据…第二列中的第一个值为50。那么50比最大X范围40大。您希望得到什么?在图形的边界处剪切?对。绝对。与在y范围内re也大于40,但在边界内。我的问题是为什么第一个数据点绘制在最大y轴值之上,因此超出图表边界。好吧,或者复制第一条数据线似乎也能工作。似乎是初始化问题。回答THX!你能添加gnuplot代码自动解决吗感谢您展示一个只支持gnuplot的解决方案。我学到了一些新的东西。THX。我对gnuplot和它的强大功能感到非常高兴。为了让它变得更好,您可以填写一份bug报告吗?或者我应该这样做。我看到您经验丰富,可能已经做到了,而且比我快得多,所以我更喜欢you;)在测试解决方案之后,重复第一行,我不得不说,在我的情况下,这不起作用,可能是因为使用了时间设置的扩展数据。但是将y值的第一行加上0效果很好。@onemorequestion“不起作用”是什么意思?结果或错误消息是什么?你在问题中没有提到你有时间数据,但这不应该起作用。如果我看到你真正的(相关的)代码,我可能会告诉你(g)上发生了什么(wr)。
1   50  35  30   5
2   55  30  20   5
17  51  44  30  12
20   1   1   1   1
# https://stackoverflow.com/a/67151340/7295599
### plot with filledcurves
reset session

FileToDatablock(f,d) = GPVAL_SYSNAME[1:7] eq "Windows" ? \
                       sprintf('< echo   %s ^<^<EOD  & type "%s"',d,f) : \
                       sprintf('< echo "\%s   <<EOD" & cat  "%s"',d,f)     # Linux/MacOS

FILE = 'Test.dat'
load FileToDatablock(FILE,'$Data')

set print $Data2
    print $Data[1]   # only first line
    print $Data
set print

unset y2tics;set y2range [0:40]
set y2tics 10
set yrange [0:40]
set ytics 10 mirror
set style fill solid 1.00 border
unset key

plot $Data2 u 1:2 every ::0::0 w fillsteps lc 'light-goldenrod', \
        '' u 1:2 w fillsteps lc 'light-goldenrod', \
        '' u 1:3 w fillsteps lc 'gray40', \
        '' u 1:4 w fillsteps lc 'web-green', \
        '' u 1:5 w fillsteps lc 'light-green'
### end of code