在 Gnuplot 中生成带有误差条的 3D 图

Generating 3D plot with error bars in Gnuplot

我有一个形式为

的数据集
x,y,z,zerr

并想要生成它的三维图,包括 z 值的误差线。 所以我想要的是像

这样的情节
splot "datafile.dat" using 1:2:3

它给出了一个常规的 3D 图,但它还应该包括误差线。 我试过使用

splot "datafile.dat" using 1:2:3:4 with errorbars

但这只会再次生成相同的图,不会显示任何误差线。 在 Gnuplot 中有没有办法做到这一点? 如果不是,有没有办法使用 matplotlib 在 Python 中做到这一点? 如果是这样,我可能会改用它。

当我检查 gnuplot 帮助 (5.2.8) 时,我很惊讶我找不到像 zerrorbar 这样的东西。也许出于某种原因?不管它是存在还是我只是没有找到它,您都可以使用 with vectors 自己完成。 也许下面的例子就是你要找的。

代码:

### zerrorbars via with vectors
reset session

$Data <<EOD
0    0.5  0    0.2
1    0    0    0.3
0    1    0    0.4
0.5  1    1    0.5
EOD

unset key
set ztics 0.5
set style arrow 1 heads size 0.01,90 lc "red"

splot $Data u 1:2:3 w p pt 7 lc "black", \
      '' u 1:2:(-):(0):(0):(2*) w vectors as 1
### end of code

结果:

Gnuplot 确实具有 3D 绘图样式 zerror,其中包括绘制为阴影区域而不是单个条形的错误范围。否则,您将不得不在单独的绘图子句中构造点、线和误差线。请注意,3D 矢量的输入数据规范是 x y z delta-x delta-y delta-z 这是显示所有这些的图。为了将 zerror 变体与其他变体分开,我已将 x 值强制为 0 或 1。

set view 60, 120
set xyplane at 0
set grid x y z vertical linewidth 1
set yrange [200:500]
set xrange [1.5 : 0]
set style fill transparent solid 0.25

set style arrow 1 heads size screen 0.005, 90
set style arrow 1 lc "blue" lw 1.5

splot 'DATA' using (0):2:3:4 with zerror title "with zerror", \
      '' using (1):2:3 with lines title "with lines", \
      '' using (1):2:3 with points pt 7 lc "black" title "with points", \
      '' using (1):2:(-):(0):(0):(2.*) with vector as 1 title "with vectors"