# Plotting in phase space with Makie.jl

**URL:** <https://discourse.julialang.org/t/plotting-in-phase-space-with-makie-jl/70652>\
**Category:** Modelling & Simulations\
**Tags:** plotting, makie\
**Created:** [October 30, 2021, 9:53am UTC](https://discourse.julialang.org/t/plotting-in-phase-space-with-makie-jl/70652 "2021-10-30T09:53:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![baumer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baumer/32/25089_2.png) [@baumer](https://discourse.julialang.org/u/baumer)\
**Post date:** [October 30, 2021, 9:53am UTC](https://discourse.julialang.org/t/plotting-in-phase-space-with-makie-jl/70652/1 "2021-10-30T09:53:01Z")

</div>

I have an `10-element Vector{Array{Float64, 6}}:` that gives the solution to a 6D + time PDE at every point in phase space on a certain interval as it progress through 10 time steps (hence the 10-element vector).

I want to plot this as two three-dimensional volume plots (3D for velocity space + 3D for space) animated through time. **Is there any way to do this with Makie.jl?**

I am setting up my input data (in the context of a larger program) like so

```julia
ts, xs, ys, zs, vxs, vys, vzs = [0:0.1:1 for d in domains] # 7-element Vector{StepRangeLen...
u = [collect(sol.u([t,x,y,z,vx,vy,vz]) for x in xs, y in ys, z in zs, vx in vxs, vy in vys, vz in vzs) for t in ts] # 11-element Vector{Array{Float64, 6}}

```

But you can test a similar data structure with `sol = [rand(10,10,10,10,10,t) for t in 1:10]`

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 30, 2021, 12:46pm UTC](https://discourse.julialang.org/t/plotting-in-phase-space-with-makie-jl/70652/2 "2021-10-30T12:46:26Z")

</div>

I’m not sure if I misunderstand your data and if this solution is plain wrong, but have a look:

```julia
using GLMakie
GLMakie.activate!()

ts = 1:10
data = [rand(10,10,10,10,10,10) for t in ts]

i = Observable(1)

f = Figure()

data_1 = @lift(data[$i][:, :, :, 1, 1, 1])
data_2 = @lift(data[$i][1, 1, 1, :, :, :])

volume(f[1, 1], data_1, axis = (;type = Axis3))
volume(f[1, 2], data_2, axis = (;type = Axis3))

ls = labelslider!(f, "t", ts)
f[2, 1:2] = ls.layout
connect!(i, ls.slider.value)

f

```

![volumes](https://global.discourse-cdn.com/julialang/original/3X/7/7/779d786e704c42f995d47b013276564216d450b3.gif)

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [October 30, 2021, 3:30pm UTC](https://discourse.julialang.org/t/plotting-in-phase-space-with-makie-jl/70652/3 "2021-10-30T15:30:57Z")

</div>

I believe that since this is for points, instead of `volume` is a `meshscatter` for all `Point3f` s. Other than that, looks awesome.

---

<div class="post-metadata">

**Author:** ![baumer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baumer/32/25089_2.png) [@baumer](https://discourse.julialang.org/u/baumer)\
**Post date:** [November 11, 2021, 2:05pm UTC](https://discourse.julialang.org/t/plotting-in-phase-space-with-makie-jl/70652/4 "2021-11-11T14:05:46Z")

</div>

@lazarusA  
How do you mean that? changing `volume(f[1, 1], data_1, axis = (;type = Axis3))` with `meshscatter(f[1, 1], data_1, axis = (;type = Axis3))` would be more accurate?
