使用这个 gnuplotting entry 作为灵感,我试图创建一个 3d 直方图,如下所示:
3d - 具有多个图的 Gnuplot 3d depthorder-LMLPHP
但是,在高角度 View 下,不尊重 depthorder:
3d - 具有多个图的 Gnuplot 3d depthorder-LMLPHP

用于生成绘图的 gnuplot ( 版本 5.2 ) 命令包括:

set terminal pngcairo  enhanced  size 800,600
set output "cube_depthorder.png"
set cbrange [0:10]
set palette defined ( 1 '#ff4c4d', 2 '#ce4c7d', 3 '#ae559e', 4 '#df866d', 5 '#ffb66d', 6 '#ffe7cf', 7 '#cecece', 8 '#6d6d6d', 9 '#4c4c8e', 10 '#4c4cef' )
set view 60,45,1,1
set xrange [-0.09:1.99]
set xyplane at 0
set yrange [-0.1125:2.0125]
set pm3d at s depthorder border
unset colorbox
splot   "-" binary record=(5,4) format="%double%double%double"   using 1:2:3 notitle with lines  dt solid  linecolor  rgb  "black "  ,   "-" binary record=(5,4) format="%double%double%double"   using 1:2:3 notitle with lines  dt solid  linecolor  rgb  "black "  ,   "-" binary record=(5,4) format="%double%double%double"   using 1:2:3 notitle with lines  dt solid  linecolor  rgb  "black "  ,   "-" binary record=(5,4) format="%double%double%double"   using 1:2:3 notitle with lines  dt solid  linecolor  rgb  "black "

正如所见, splot 命令包含四个条目。在将它们发送到 splot 之前,我尝试将这些条目从最高到最短进行排序,但这对 depthorder 没有变化。

我怀疑 depthorder 测量从四边形中心到绘图视口(viewport)的四边形,并按距离排序。有一个角度,高四边形的中心比较短的四边形更近,因此以不同的顺序绘制。

这个怀疑是正确的,还是这里有另一个问题?在这种情况下,是否有解决方案可以“正确”测量 depthorder

对于那些希望重新创建这些图形的人,这里有一个包含等值线的数据文件(每条线是五个 (x,y,z) 点,每个立方体有 4 条线(2 个水平和 2 个垂直)和四个立方体) :

0 1 0
0 1.9 0
0 1.9 2
0 1 2
0 1 0

1 1 0
1 1.9 0
1 1.9 1
1 1 1
1 1 0

0 0 0
0 0.9 0
0 0.9 1
0 0 1
0 0 0

1 0 0
1 0.9 0
1 0.9 0
1 0 0
1 0 0


0.9 1 0
0.9 1.9 0
0.9 1.9 2
0.9 1 2
0.9 1 0

1.9 1 0
1.9 1.9 0
1.9 1.9 1
1.9 1 1
1.9 1 0

0.9 0 0
0.9 0.9 0
0.9 0.9 1
0.9 0 1
0.9 0 0

1.9 0 0
1.9 0.9 0
1.9 0.9 0
1.9 0 0
1.9 0 0


0 1 0
0 1.9 0
0.9 1.9 0
0.9 1 0
0 1 0

1 1 0
1 1.9 0
1.9 1.9 0
1.9 1 0
1 1 0

0 0 0
0 0.9 0
0.9 0.9 0
0.9 0 0
0 0 0

1 0 0
1 0.9 0
1.9 0.9 0
1.9 0 0
1 0 0


0 1 2
0 1.9 2
0.9 1.9 2
0.9 1 2
0 1 2

1 1 1
1 1.9 1
1.9 1.9 1
1.9 1 1
1 1 1

0 0 1
0 0.9 1
0.9 0.9 1
0.9 0 1
0 0 1

1 0 0
1 0.9 0
1.9 0.9 0
1.9 0 0
1 0 0 

最佳答案

我知道这是一个老问题,但受到 same gnuplotting entry 的启发,我决定尝试一些真正适用于 gnuplot 5.2.7 的方法。它实际上是 概念的证明 !
我意识到,即使使用 depthorder base ,只需按特定顺序创建立方体面即可实现正确的 z 顺序。
为了说明这一点,我使用了以下数据文件来绘制“立方体”。

0.1 0.1 0.0
0.9 0.1 0.0
0.9 0.1 1.0
0.1 0.1 1.0
0.1 0.1 0.0

0.9 0.1 0.0
0.9 0.9 0.0
0.9 0.9 1.0
0.9 0.1 1.0
0.9 0.1 0.0

0.9 0.1 1.0
0.9 0.9 1.0
0.1 0.9 1.0
0.1 0.1 1.0
0.9 0.1 1.0

0.9 0.1 0.0
0.9 0.9 0.0
0.1 0.9 0.0
0.1 0.1 0.0
0.9 0.1 0.0

使用此代码...
reset
set terminal pngcairo font "Ubuntu,10" size 1000,800
set output "3D_Graph.png"
set tics out nomirror
unset key
set xyplane at 0
unset colorbox

set arrow 1 from 0.55,0.40,0 to 1.45,0.4,0 nohead
set arrow 2 from 0.55,0.32,0 to 0.55,0.47,0 nohead
set arrow 3 from 1.45,0.32,0 to 1.45,0.47,0 nohead

set arrow 4 from 1.60,0.55,0 to 1.60,1.45,0 nohead
set arrow 5 from 1.55,0.55,0 to 1.65,0.55,0 nohead
set arrow  from 1.55,1.45,0 to 1.65,1.45,0 nohead

set style textbox opaque noborder fillcolor rgb "white"
set label 1 "0.9" at 0.95,0.2,0.0 boxed
set label 2 "0.9" at 1.70,1.0,0.0 boxed

set style line  1 lw 1.5 lc rgb "#fde725"

# viridis colormap
set palette defined(\
    1 "#440154",\
    2 "#472c7a",\
    3 "#3b518b",\
    4 "#2c718e",\
    5 "#21908d",\
    6 "#27ad81",\
    7 "#5cc863",\
    8 "#aadc32",\
    9 "#fde725"\
)
# ================================================================================
set multiplot layout 2,2
set xtics 1
set ytics 1
set view equal xyz
set view ,,1.5,1
set cbrange [0:1]
set grid ls -1 lc "gray"
set pm3d depthorder hidden3d
set pm3d implicit
unset hidden3d
set title "{/:Bold single cube}"

splot [0:2][0:2][0:1] "cube_points.dat" u ($1+0.5):($2+0.5):($3):(0) w l ls 1
unset for [i=1:6] arrow i
unset for [i=1:2] label i
# --------------------------------------------------------------------------------
set grid xtics ytics ztics vertical layerdefault ls -1 lc "gray"
set view equal xy
set view ,,1.75,0.55
set xrange [0.25:6.6]
set yrange [0.25:4.0]
set zrange [0:100]
set ztics 20
set cbrange [0:*]

set object polygon from \
    graph 0, 0, 0 to \
    graph 1, 0, 0 to \
    graph 1, 1, 0 to \
    graph 0, 1, 0 to \
    graph 0, 0, 0 fc rgb "gray" fs transparent solid 0.50 noborder

set pm3d depthorder base border lw 0.5
set title "{/:Bold pm3d with depthorder base border lw 0.5}"

splot \
    "cube_points.dat" u ($1+0.5):($2+0.5):($3*15):(1) w pm3d,\
    "cube_points.dat" u ($1+0.5):($2+1.5):($3*65):(1) w pm3d,\
    "cube_points.dat" u ($1+0.5):($2+2.5):($3*85):(1) w pm3d,\
    "cube_points.dat" u ($1+1.5):($2+0.5):($3*30):(2) w pm3d,\
    "cube_points.dat" u ($1+1.5):($2+2.5):($3*75):(2) w pm3d,\
    "cube_points.dat" u ($1+1.5):($2+1.5):($3*50):(2) w pm3d,\
    "cube_points.dat" u ($1+2.5):($2+0.5):($3*30):(3) w pm3d,\
    "cube_points.dat" u ($1+2.5):($2+1.5):($3*40):(3) w pm3d,\
    "cube_points.dat" u ($1+2.5):($2+2.5):($3*60):(3) w pm3d,\
    "cube_points.dat" u ($1+3.5):($2+0.5):($3*20):(4) w pm3d,\
    "cube_points.dat" u ($1+3.5):($2+1.5):($3*50):(4) w pm3d,\
    "cube_points.dat" u ($1+3.5):($2+2.5):($3*85):(4) w pm3d,\
    "cube_points.dat" u ($1+4.5):($2+0.5):($3*25):(5) w pm3d,\
    "cube_points.dat" u ($1+4.5):($2+1.5):($3*40):(5) w pm3d,\
    "cube_points.dat" u ($1+4.5):($2+2.5):($3*50):(5) w pm3d,\
    "cube_points.dat" u ($1+5.5):($2+0.5):($3*15):(6) w pm3d,\
    "cube_points.dat" u ($1+5.5):($2+1.5):($3*30):(6) w pm3d,\
    "cube_points.dat" u ($1+5.5):($2+2.5):($3*40):(6) w pm3d

# --------------------------------------------------------------------------------

set pm3d depthorder base lighting noborder
set title "{/:Bold pm3d with depthorder base lighting noborder}"
replot

# --------------------------------------------------------------------------------

set pm3d depthorder base lighting border lw 0.5
set title "{/:Bold pm3d with depthorder base lighting border lw 0.5}"
replot
unset multiplot

...我能够达到这个结果:

3d - 具有多个图的 Gnuplot 3d depthorder-LMLPHP

即使在高角度 View 下也能正常工作:

3d - 具有多个图的 Gnuplot 3d depthorder-LMLPHP

3d - 具有多个图的 Gnuplot 3d depthorder-LMLPHP

当然,此代码无法读取 x y z 类型的数据文件或创建 3D 聚类条形图,但这是一个开始。

关于3d - 具有多个图的 Gnuplot 3d depthorder,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50822781/

10-10 02:54