# Makie - update volumeslices

**URL:** <https://discourse.julialang.org/t/makie-update-volumeslices/116729>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [July 7, 2024, 4:50pm UTC](https://discourse.julialang.org/t/makie-update-volumeslices/116729 "2024-07-07T16:50:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg\_Melnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oleg_melnik/32/210496_2.png) [@Oleg\_Melnik](https://discourse.julialang.org/u/Oleg_Melnik)\
**Post date:** [July 7, 2024, 4:50pm UTC](https://discourse.julialang.org/t/makie-update-volumeslices/116729/1 "2024-07-07T16:50:43Z")

</div>

I am trying to add a timestep slider to the standard example from [volumeslices | Makie](https://docs.makie.org/v0.21/reference/plots/volumeslices)  
to update the vol array  
I did not find a method how to update the dataset and redraw the diagram after I change the value of the slider. I can only update slices positions.  
Please help.  
Oleg

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [July 7, 2024, 6:05pm UTC](https://discourse.julialang.org/t/makie-update-volumeslices/116729/2 "2024-07-07T18:05:33Z")

</div>

something like that?

```julia
for f in 1:50
    set_close_to!(sl_yz, f)
    sleep(0.2)
end

for _ in 1:3
    for f in -49:2:49
        set_close_to!(sl_yz, abs(f))
        sleep(0.2)
    end
end

```

---

<div class="post-metadata">

**Author:** ![Oleg\_Melnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oleg_melnik/32/210496_2.png) [@Oleg\_Melnik](https://discourse.julialang.org/u/Oleg_Melnik)\
**Post date:** [July 7, 2024, 6:22pm UTC](https://discourse.julialang.org/t/makie-update-volumeslices/116729/3 "2024-07-07T18:22:15Z")

</div>

I do not need an animation. Just to be able to read time slider and update the figure with a new dataset.

> using GLMakie, HDF5  
> fig = Figure()  
> ax = LScene(fig[1, 1], show\_axis=false)  
> fid=h5open(“./simulation\_data.h5”,“r”)  
> k=keys(fid);  
> lx,ly,lz=read(fid,“coords/length”)  
> vol=zeros(30,30,30,10)  
> for kt in 1:length(k)-1  
> global kk=k[kt];  
> vol[:,:,:,kt]=read(fid,“$kk/array”)  
> end

sz=size(vol)  
x = LinRange(0, lx, sz[1])  
y = LinRange(0, ly, sz[2])  
z = LinRange(0, lz, sz[3])  
z\_index = Observable{Any}(1)  
sgrid = SliderGrid(  
fig[2, 1],  
(label = “yz plane - x axis”, range = 1:length(x)),  
(label = “xz plane - y axis”, range = 1:length(y)),  
(label = “xy plane - z axis”, range = 1:length(z)),  
(label = “time” , range = 1:length(k)-1),  
)

lo = sgrid.layout  
nc = ncols(lo)

# connect sliders to `volumeslices` update methods

Volp = vol[:, :, :, 1]  
Volp = @lift(vol[:, :, :, $z\_index])  
plt = volumeslices!(ax, x, y, z, Volp,colormap=:plasma); Colorbar(fig[1, 1][1, 2],plt)

sl\_yz, sl\_xz, sl\_xy, sl\_t= sgrid.sliders

set\_close\_to!(sl\_yz, .5length(x))  
set\_close\_to!(sl\_xz, .5length(y))  
set\_close\_to!(sl\_xy, .5length(z))  
set\_close\_to!(sl\_t, 1)

on(sl\_yz.value) do v; plt[:update\_yz] end  
on(sl\_xz.value) do v; plt[:update\_xz] end  
on(sl\_xy.value) do v; plt[:update\_xy] end  
connect!(z\_index, sl\_t.value)

# add toggles to show/hide heatmaps

hmaps = [plt[Symbol(:heatmap\_, s)] for s ∈ (:yz, :xz, :xy)]  
toggles = [Toggle(lo[i, nc + 1], active = true) for i ∈ 1:length(hmaps)]

map(zip(hmaps, toggles)) do (h, t)  
connect!(h.visible, t.active)  
end

#cam3d!(ax.scene, projectiontype=Makie.Orthographic)

fig

---

<div class="post-metadata">

**Author:** ![hunKing](https://avatars.discourse-cdn.com/v4/letter/h/e9bcb4/32.png) [@hunKing](https://discourse.julialang.org/u/hunKing)\
**Post date:** [August 22, 2024, 9:14pm UTC](https://discourse.julialang.org/t/makie-update-volumeslices/116729/4 "2024-08-22T21:14:18Z")

</div>

Hey is this code working for your purpose or you are still looking for a solution? I wanted something like that too.
