# Updating a volume plot

**URL:** https://discourse.julialang.org/t/updating-a-volume-plot/103987
**Category:** Visualization
**Created:** [September 18, 2023, 2:04pm UTC](https://discourse.julialang.org/t/updating-a-volume-plot/103987 "2023-09-18T14:04:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Knud\_Sorensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/knud_sorensen/32/52401_2.png) [@Knud\_Sorensen](https://discourse.julialang.org/u/Knud_Sorensen)
#### Post date: [September 18, 2023, 2:04pm UTC](https://discourse.julialang.org/t/updating-a-volume-plot/103987/1 "2023-09-18T14:04:14Z")

</div>

Hi.

I am plotting a volume plot. Like `volume(vol; algorithm=:absorption)`  
But I want to update the plot with new data (nvol)!

But when I run `volume!(nvol; algorithm=:absorption)` it adds the new data to the old data instead of replacing it. Is there a way to get `volume!` to replace the data instead of adding it to the old data ?

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [September 18, 2023, 3:40pm UTC](https://discourse.julialang.org/t/updating-a-volume-plot/103987/2 "2023-09-18T15:40:36Z")

</div>

This is how you animate in Makie:  
[https://docs.makie.org/stable/explanations/animation/](https://docs.makie.org/stable/explanations/animation/)

So, you need to do something like this:

```julia
fig, ax, pl = volume(...)
pl[1] = new_volume

```

---

<div class="post-metadata">

### Author: ![Knud\_Sorensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/knud_sorensen/32/52401_2.png) [@Knud\_Sorensen](https://discourse.julialang.org/u/Knud_Sorensen)
#### Post date: [September 19, 2023, 12:07pm UTC](https://discourse.julialang.org/t/updating-a-volume-plot/103987/3 "2023-09-19T12:07:46Z")

</div>

Thanks, your answer got me on the right track.

Here is an example I made.  
`using GLMakie

f(x,y,z,k,v) = sin(k\*cos(v)\*x)_sin(k_sin(v)\*y)_cosh(k_z)

xs, ys, zs = [-10:0.1:10 for d in range(1,3)]

vol = Observable([f(x,y,z,1.0,0.0) for x in xs, y in xs, z in zs])

fig=volume(xs,ys,zs,vol; colormap=:redsblues, colorrange=(-1000,1000),algorithm=:absorption)  
display(fig)

for v = 0.0:0.1:pi  
vol=[f(x,y,z,1.0,v) for x in xs, y in xs, z in zs]  
println(“phi = $v”)  
sleep(1)  
end`
