Array of boxes using Makie and volume

Hi,
the examples from the Makie documentation show how to build a cube (using volume), but if I try to update the scene with a new one, they overlap. Any ideas on how to solve this. I want to create an array of cubes.

using Makie
r = LinRange(-4, 4, 100);  # our value range, cube centered at 0 
r1 = LinRange(5, 8, 100);  # our value range, cube centered at 6

 ρ(x, y, z) = exp(-(abs(0.1*x^2))) # function (charge density)

scene = Scene(backgroundcolor = :black)

 volume!(
     scene,
     r, r, r,          # coordinates to plot on
     ρ,                # charge density (functions as colorant)
     algorithm = :mip  # maximum-intensity-projection
 )
volume!(
     scene,
     r1, r1, r1,          # coordinates to plot on
     ρ,                # charge density (functions as colorant)
     algorithm = :mip  # maximum-intensity-projection
 )
 scene[Axis].names.textcolor = :white # let axis labels be seen on dark background
 scene

Not Makie, but good for now.

using PlotlyJS
function cube_form(center = 0.0)
     mesh3d(
        x=[0, 0, 1, 1, 0, 0, 1, 1],
        y=[0, 1, 1, 0, 0, 1, 1, 0] .+ center,
        z=[0, 0, 0, 0, 1, 1, 1, 1],
        i=[7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2],
        j=[3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3],
        k=[0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6],
        intensity=range(0, stop=1, length=8),
        colorscale=[
            [0, "gold"],
            [0.5, "mediumturquoise"],
            [1, "gold"]
        ],
    showscale=false,
    opacity = 0.5
    )
end

t = cube_form()
t1 = cube_form(1.5)
t2 = cube_form(3.0)
plot([t, t1, t2])

1 Like