绘制步骤图总是会导致超出边界的结果。
如何解决这个问题?有什么想法吗?太棒了!
妇女权利委员会是:
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';结果是:

使用的软件是:
GnuketVersion5.2补丁级别8
发布于 2021-04-18 17:11:40
好吧,现在我明白你的意思了。看起来像是一个小错误(或者我们有限的理解)。我不能马上知道为什么会这样,但是您可以通过在开头添加一行,其中包含第一个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结果:

添加:(自动复制第一行,以解决bug(!?))
为了解决这个问题(我称之为意外或错误),您需要自动复制第一行。然而,使用外部工具肯定会有不同的简单方法,这并不能保证平台的独立性。因此,以下是几种可能的gnuplot解决方案之一。
将文件放入数据库(此处:gnuplot: load datafile 1:1 into datablock)
$Data) (参见将$Data的第一行放入新的数据库(此处:$Data2) ),确保第一行不是头行或注释行,即再次将第一行完整的数据库$Data打印到$Data2.数据: (Test.dat)
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 codehttps://stackoverflow.com/questions/67148858
复制相似问题