使用此gnuplotting entry作为灵感,我正在尝试创建如下所示的三维直方图:
但是,在高角度视图下,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

答案 0 :(得分:4)
现在支持这样的3D箱图作为gnuplot开发版本中的基本绘图类型。看到这个在线示例: http://gnuplot.sourceforge.net/demo_5.3/3dboxes.html
使这项工作的技巧是框面必须按基础的z值排序。这是在新的命令变体
中实现的设置pm3d depthorder base
我不知道在早期版本的gnuplot中是否有任何正确的方法。
答案 1 :(得分: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
...我能够达到此结果:
即使在高视角下也可以使用:
当然,该代码无法读取x y z
型数据文件或创建3D群集条形图,但这只是一个开始。