Using this gnuplotting entry as inspiration, I am attempting to create a 3d histogram plot like shown:
However, under high-angled views, the depthorder
is not respected:
The gnuplot (version 5.2) commands used to generate the plots include:
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 "
As seen, the splot command contains four entries. I have tried sorting these entries from tallest to shortest before sending them to splot, but that has no change on depthorder
.
My suspicion is that depthorder
measures the quadrangles from their centers to the viewport of the plot and sorts by distance. There is an angle then that the tall quadrangles have centers closer than the shorter quadrangles, and consequently get drawn in a different order.
Is this suspicion correct, or is there another issue at play here? Is there a solution to get depthorder
measured 'correctly' in this case?
For those who wish to recreate these graphs, here is a data file containing the isolines (each line is five (x,y,z) points, there are 4 lines for each cube (2 horizontal and 2 vertical), and four cubes):
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 boxplots like that are now supported as a basic plot type in the development version of gnuplot. See this online example: http://gnuplot.sourceforge.net/demo_5.3/3dboxes.html
The trick to make this work is that the box faces must be sorted by the z value at the base. This is implemented in a new command variant
set pm3d depthorder base
I am not aware of any way to do this properly in earlier versions of gnuplot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With