# How to create an animation based on t, x, y and z data?

**URL:** <https://discourse.julialang.org/t/how-to-create-an-animation-based-on-t-x-y-and-z-data/25672>\
**Category:** General Usage\
**Tags:** plotting, plots, animations\
**Created:** [June 26, 2019, 2:06am UTC](https://discourse.julialang.org/t/how-to-create-an-animation-based-on-t-x-y-and-z-data/25672 "2019-06-26T02:06:57Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![CM1](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@CM1](https://discourse.julialang.org/u/CM1)\
**Post date:** [October 31, 2023, 11:43am UTC](https://discourse.julialang.org/t/how-to-create-an-animation-based-on-t-x-y-and-z-data/25672/7 "2023-10-31T11:43:37Z")

</div>

A bit late to the party, but I am just starting to learn Julia and came across the Lorenz attractor example in the docs. While the approach is quite intuitive and elegant, I am struggling to extend this to subplots, i.e. two trajectories of the attractor next to each other.

I have tried to push to the subplots instead of the overall plot, but as far as I understand the error message, subplots do not support the pushing of new data?

```julia
N = 200

u1 = 20*rand(3, N)
u2 = 15*ones(3, N)

plt = plot3d(
    1,
    xlim = (-30, 30),
    ylim = (-30, 30),
    zlim = (0, 60),
    title = ["Some trajectory" "Other trajectory"],
    legend = false,
    marker = 2,
    layout = (1, 2)
)

@gif for i in range(1, size(u1, 2))
    push!(plt[1], u1[:, i]...)
    push!(plt[2], u2[:, i]...)
end every 10

```

Giving me the following error:

```julia
MethodError: no method matching push!(::Plots.Subplot{Plots.GRBackend}, ::Float64)

Closest candidates are:
  push!(::Any, ::Any, !Matched::Any)
   @ Base abstractarray.jl:3389
  push!(::Any, ::Any, !Matched::Any, !Matched::Any...)
   @ Base abstractarray.jl:3390
  push!(!Matched::StatsBase.AbstractHistogram{T, 1}, ::Real) where T
   @ StatsBase some_path\.julia\packages\StatsBase\WLz8A\src\hist.jl:294
  ...

Stacktrace:
 [1] push!(A::Plots.Subplot{Plots.GRBackend}, a::Float64, b::Float64)
   @ Base .\abstractarray.jl:3389
 [2] push!(A::Plots.Subplot{Plots.GRBackend}, a::Float64, b::Float64, c::Float64)
   @ Base .\abstractarray.jl:3390
 [3] macro expansion
   @ some_path\MMDS_Julia\ex2.ipynb:19 [inlined]
 [4] top-level scope
   @ some_path\.julia\packages\Plots\sxUvK\src\animation.jl:251

```

Any suggestion how to achieve the wanted effect?

---

_[View the full topic](https://discourse.julialang.org/t/how-to-create-an-animation-based-on-t-x-y-and-z-data/25672)._
