在GNUPLOT中将错误条绘制为阴影区域

在GNUPLOT中将错误条绘制为阴影区域,gnuplot,Gnuplot,我用Gnuplot中的fsteps函数绘制了一个图(X-top轴,Y-bottom轴)。接下来,我尝试将错误条作为着色区域(透明)添加到图形中,但无法在图形上绘制它。下面是迄今为止我尝试过的代码,并附上了图表 #!/usr/bin/gnuplot reset set border lw 30 set term pngcairo size 10000,10000 font "arial-Bold,130" set output 'out.png' unset key set size ratio

我用Gnuplot中的fsteps函数绘制了一个图(X-top轴,Y-bottom轴)。接下来,我尝试将错误条作为着色区域(透明)添加到图形中,但无法在图形上绘制它。下面是迄今为止我尝试过的代码,并附上了图表

#!/usr/bin/gnuplot
reset
set border lw 30
set term pngcairo size 10000,10000 font "arial-Bold,130"
set output 'out.png'
unset key
set size ratio 1.2
set style data lines
set xtics format ""
set x2tics nomirror
set ytics out nomirror
set ytics 0,20 
set x2label "Vs (km/s)" offset -1.0
set ylabel 'Depth (km)' offset 1.5
set xrange [2.5:4.8]
set yrange [314:0]
set label 3 at 2,120
set key samplen 1.7 at 3.0,135
#
set label 1 '(a)' font "arial-Bold,130" at 0.8,15 right 
set label 3 "C3 (MNAI)" center font "arial-Bold,130"
set style fill transparent solid 0.25
set style fill noborder

plot 'MAN.inmd' lc rgb 'blue' lw 35 title "Initial  model"   with fsteps,\
     'MAN.outmd' using 1:2 lc rgb 'red' lw 35  dt"-" title "Inverted model" with fsteps ,\
     'MAN.outmd' using 1:($2-$3):($2+$3) with filledcurve lc "blue" notitle, 
文件MAN.outmd X Y Z的示例数据(错误)

我希望输出应如下所示(示例)


gnuplot可以轻松填充两条“水平”曲线之间的区域(即唯一的x值),但据我所知,不是两条垂直曲线之间的区域。然而,gnuplot可以填充一些封闭区域。因此,解决方法是创建围绕要着色区域的数据点。为此,您可以将数据“打印”到一个数据块中,一次使用
x-dx
进行“向前”,一次使用
x+dx
进行“向后”。如果数据已经存在于数据块中,那么这是最容易做到的,因为这样可以轻松地前后循环数据。如果您的数据保存在文件中,请参见此处:

代码:

### fill between vertical curves
reset session

$Data <<EOD
0        3         0
0.4475   3.1       0
0.4475   3.5       0
2.6738   3.6       0.0552
2.6738   5         0.0552
3.8441   5.1       0.0592
3.8441   8         0.0592
3.6302   8.1       0.0395
3.6302   15.935    0.0395
4.5176   15.1      0.041
4.5176   113.296   0.041
4.2443   113.3     0.1024
4.2443   214       0.1024
4.4584   214.1     0.1077
4.4584   314       0.1077
EOD

# create datablock with circumference of shaded area
set print $XErrorFill
    do for [i=1:|$Data|] {
        print real(word($Data[i],1))-real(word($Data[i],3)), real(word($Data[i],2))
    }
    do for [i=|$Data|:1:-1] {
        print real(word($Data[i],1))+real(word($Data[i],3)), real(word($Data[i],2))
    }
set print

set yrange [:] reverse
set style fill noborder

plot $XErrorFill u 1:2 w filledcurves lc "light-grey" notitle, \
     $Data u 1:2 w l lw 1.5 lc rgb "red" notitle
### end of code
垂直曲线之间的填充 重置会话
$Data您的代码是/不完整的,我猜在第一个绘图命令行中可能缺少使用1:3的
。你能检查一下并改正一下吗?顺便问一下,你确定你需要10000x1000像素的分辨率吗?您希望填充哪个区域?
$2
$3
之间的曲线?文件MAN.outmd有三列。X值、Y值和Z标准误差。对于这个XY值,我想将误差绘制为阴影区域。Z列是什么,x误差还是y误差?如果是y误差,您希望如何对垂直线进行着色?如果是x错误,您希望如何对水平线进行着色?你能提供一些示例数据吗?也许你需要一个手绘草图?theozh我编辑了我的问题,看看。这是一个x错误
### fill between vertical curves
reset session

$Data <<EOD
0        3         0
0.4475   3.1       0
0.4475   3.5       0
2.6738   3.6       0.0552
2.6738   5         0.0552
3.8441   5.1       0.0592
3.8441   8         0.0592
3.6302   8.1       0.0395
3.6302   15.935    0.0395
4.5176   15.1      0.041
4.5176   113.296   0.041
4.2443   113.3     0.1024
4.2443   214       0.1024
4.4584   214.1     0.1077
4.4584   314       0.1077
EOD

# create datablock with circumference of shaded area
set print $XErrorFill
    do for [i=1:|$Data|] {
        print real(word($Data[i],1))-real(word($Data[i],3)), real(word($Data[i],2))
    }
    do for [i=|$Data|:1:-1] {
        print real(word($Data[i],1))+real(word($Data[i],3)), real(word($Data[i],2))
    }
set print

set yrange [:] reverse
set style fill noborder

plot $XErrorFill u 1:2 w filledcurves lc "light-grey" notitle, \
     $Data u 1:2 w l lw 1.5 lc rgb "red" notitle
### end of code