代码之家  ›  专栏  ›  技术社区  ›  cms

带多个绘图的gnuplot 3d depthorder

  •  3
  • cms  · 技术社区  · 7 年前

    使用此 gnuplotting entry 作为灵感,我试图创建一个三维柱状图,如图所示: respects depthorder
    然而,在高角度视图下, depthorder 不受尊重: does not respect depthorder

    格努普洛特( 版本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之前将它们从最高的排序到最短的排序,但这没有改变 小精灵 .

    我的怀疑是 小精灵 测量四合院从其中心到绘图视图的距离,并按距离排序。然后有一个角度,高四合院的中心比短四合院的中心更近,因此会以不同的顺序绘制。

    这种怀疑是正确的,还是还有其他问题在起作用?有什么办法 小精灵 在这种情况下测量“正确”?

    对于那些希望重新创建这些图形的人,这里有一个包含等值线的数据文件(每一行是五个(x,y,z)点,每一个立方体有四行(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 
    1 回复  |  直到 7 年前
        1
  •  4
  •   Ethan    7 年前

    在gnuplot的开发版本中,类似这样的3d boxplot现在作为一种基本的绘图类型受到支持。请参阅此联机示例: http://gnuplot.sourceforge.net/demo_5.3/3dboxes.html

    实现这一点的诀窍是,长方体的面必须按底部的z值排序。这是在一个新的命令变量中实现的

    设置PM3D除雾器底座

    我不知道在gnuplot的早期版本中有什么方法可以正确地做到这一点。

        2
  •  0
  •   grsousajunior    5 年前

    我知道这是个老问题,但是 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 boxbar using gnuplot

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

    3D horizontal rotation

    3D vertical rotation

    当然,这段代码无法读取 x y z -键入数据文件或创建三维聚集条形图,但这只是一个开始。