#
# Demo for direct plotting of voxel data
#    splot $voxelgrid with {dots|points}
#
if (!exists("VoxelDistance")) exit

set border 0
set xzeroaxis; set yzeroaxis; set zzeroaxis;
set label 1 "X" at 4.1, 0, 0
set label 2 "Y" at 0, 4.1, 0
set label 3 "Z" at 0, 0, 4.1
set tics axis nomirror
set xyplane at 0
set key opaque box
set cblabel "$v201 voxel value" offset -6
set view 203, 227, 1.75

set palette cubehelix negative
set cbrange [0:100]

set xrange [-4:4]; set yrange [-4:4]; set zrange [-4:4]

#
# Radius 1 spheres around (-1,2,2) and (0,3,2) with values decreasing 
# linearly with distance from the center
#
set vgrid $v122 size 100
set vxrange [-4:4]; set vyrange [-4:4]; set vzrange [-4:4]

vfill '-' using 1:2:3:(1.):(100. * (1. - VoxelDistance))
-1 2 2
e

set vgrid $v032 size 100
set vxrange [-4:4]; set vyrange [-4:4]; set vzrange [-4:4]

vfill '-' using 1:2:3:(1.):(100. * (1. - VoxelDistance))
0 3 2
e

#
# Radius 2 sphere around (2,0,1) with values decreasing exponentially 
# with distance from the center
# NB: vgrid range is different from the plot range
#
set vgrid $v201 size 25
set vxrange [0:5]; set vyrange [-2.5:2.5]; set vzrange [-1:4]
vfill '-' using 1:2:3:(2.):(40. * exp(1. - VoxelDistance))
2 0 1
e

show vgrid
set title "overlapping dot plots with constant color\n" \
        . "point plot colored by exponentially decreasing voxel value"
splot $v122 with dots above 0.01 lc "blue", \
      $v032 with dots lc "red", \
      $v201 with points pt 4 lc palette lw 0.33

pause -1 "<cr> to continue"

#
# Same thing with jitter
#
set jitter
set title "Same voxel plot with jitter"
replot

pause -1 "<cr> to continue"

reset
