【问题标题】:Gnuplot 3d depthorder with multiple plots具有多个绘图的 Gnuplot 3d depthorder
【发布时间】:2018-11-22 04:23:11
【问题描述】:

gnuplotting entry 为灵感,我正在尝试创建一个 3d 直方图,如下所示:
但是,在高角度视图下,depthorder 不受尊重:

用于生成绘图的 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 测量从中心到绘图视口的四边形并按距离排序。然后有一个角度,高四边形的中心比较短的四边形更近,因此以不同的顺序绘制。

这种怀疑是正确的,还是这里有其他问题?在这种情况下,是否有解决方案可以“正确”测量 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 

【问题讨论】:

    标签: 3d gnuplot


    【解决方案1】:

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

    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
    

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

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

    当然,这段代码不能读取x y z-type 数据文件或创建 3D 集群条形图,但这只是一个开始。

    【讨论】:

    • 太棒了。我很快就会试试这个。
    【解决方案2】:

    现在在 gnuplot 的开发版本中支持将类似的 3D 箱线图作为基本绘图类型。请参阅此在线示例: http://gnuplot.sourceforge.net/demo_5.3/3dboxes.html

    完成这项工作的诀窍是,盒子面必须按底部的 z 值排序。这是在一个新的命令变体中实现的

    设置 pm3d depthorder base

    我不知道有什么方法可以在早期版本的 gnuplot 中正确执行此操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-09
      • 1970-01-01
      相关资源
      最近更新 更多