Makie control heatmaps of volumeslices

Hello everyone.

I try to use Makie to plot heatmap slices though a volume with their volumeslices functionality: volumeslices | Makie

However, i am unable to control the positions or the numbers of the slices:

using CairoMakie
nx = 25
ny = 26
nz = 27
dim = (nx,ny,nz)

imageXY = rand(nx, ny) 
imageXZ = rand(nx, nz) 
imageYZ = rand(ny, nz)  

V = zeros(dim)
V[:,:,13] .= imageXY
V[:,13,:] .= imageXZ
V[13,:,:] .= imageYZ


fig = Figure()
ax = LScene(fig[1, 1])

plt = volumeslices!(ax, 1:nx, 1:ny, 1:nz, V,
                    colorrange=(0,1))
fig

Here the images are locked to x,y,z = 0, but in order so the non-zero planes, i need to move them to the index x,y,x = 13 in this example.
I cannot follow their documentation, cause they implemented interactive sliders (which i dont want).
Does anyone know how to get control about the positions of the heatmaps?

Thanks in advance.

You’re just missing a few lines to update the positions of the slices before displaying your plot:

plt[:update_yz][](13)
plt[:update_xz][](13)
plt[:update_xy][](13)

In the Makie documentation, similar lines appear in the body of the slider update functions:

on(sl_yz.value) do v; plt[:update_yz][](v) end
on(sl_xz.value) do v; plt[:update_xz][](v) end
on(sl_xy.value) do v; plt[:update_xy][](v) end

but in your case, v is fixed and does not come from a slider value.

Complete example
using CairoMakie
using ElectronDisplay

nx = 25
ny = 26
nz = 27
dim = (nx,ny,nz)

imageXY = rand(nx, ny)
imageXZ = rand(nx, nz)
imageYZ = rand(ny, nz)

V = zeros(dim)
V[:,:,13] .= imageXY
V[:,13,:] .= imageXZ
V[13,:,:] .= imageYZ


fig = Figure()
ax = LScene(fig[1, 1])

plt = volumeslices!(ax, 1:nx, 1:ny, 1:nz, V,
                    colorrange=(0,1))

plt[:update_yz][](13)
plt[:update_xz][](13)
plt[:update_xy][](13)

fig
2 Likes

That’s admittedly a weird and otherwise undocumented interface. Probably there should be an attribute like index that takes a tuple of three integers I think.