Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot 3d depthorder with multiple plots

Tags:

gnuplot

3d

Using this gnuplotting entry as inspiration, I am attempting to create a 3d histogram plot like shown: respects depthorder
However, under high-angled views, the depthorder is not respected: does not respect depthorder

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 
like image 664
cms Avatar asked Jan 27 '23 22:01

cms


1 Answers

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.

like image 93
Ethan Avatar answered Jan 30 '23 12:01

Ethan