# Creating Animated Makie Plot in Pluto

**URL:** https://discourse.julialang.org/t/creating-animated-makie-plot-in-pluto/74464
**Category:** Pluto
**Tags:** makie
**Created:** [January 12, 2022, 4:10am UTC](https://discourse.julialang.org/t/creating-animated-makie-plot-in-pluto/74464 "2022-01-12T04:10:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [January 12, 2022, 4:10am UTC](https://discourse.julialang.org/t/creating-animated-makie-plot-in-pluto/74464/1 "2022-01-12T04:10:30Z")

</div>

Hello,

I’d like to embed an animation in my pluto NB. I don’t want to create an MP4 (if possible) - I just want the animation to loop. The animation itself is just a line plot. I tried following the post [here](https://discourse.julialang.org/t/real-time-animations-with-makie-in-pluto/63684/4). My MWE is below.

```julia
begin
    using GLMakie
	# animation settings
	framerate = 30

	# Data is x and y
	# x is a 1-dimensional grid from 0 to 1
	# y is a 100x2 matrix where each element of the second column 
	# is a vector containing the line plot at a different time step

	nframes = 2:length(y[1:end,2])

	fig, ax, pl = lines(x, y[1, 2]) # initial condition

	record(fig, nframes; framerate = framerate) do p
		pl[1] = y[nframes, 2]
	end
end

```

When I try to run the cell I get the error

```julia
MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type Float64

```

If I inspect `pl[1]` I can see what looks like the plotted points in `GeometryBasics.Point` but I have no idea how to access them. Perhaps there is something obvious here - if so I apologize, I am new to Makie.

I also tried creating the animation using `Observables`. Shown below.

```julia
begin
	oy = Observable(y[1, 2])
	fig = Figure()
	display(fig)
	ax = Axis(fig[1, 1])
	lines!(ax, x, oy)
	ylims!(ax, 0, 1)

	for time_step = 2:length(y[:, 1])
    	oy[] = y[time_step, 2]
    	sleep(0.1)
	end
end

```

When I do this I get the following error.

```julia
Plot needs to be displayed to insert additional plots

```

Any hints or ideas on how I can accomplish this? Or where I am going wrong?

---

<div class="post-metadata">

### Author: ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)
#### Post date: [January 12, 2022, 11:01am UTC](https://discourse.julialang.org/t/creating-animated-makie-plot-in-pluto/74464/2 "2022-01-12T11:01:48Z")

</div>

I think in the first case Makie is converting your inputs to arrays. You could check `pl[1]` to see if that’s true and update with `pl[1] = [y[nframes, 2]]` if it is.

---

<div class="post-metadata">

### Author: ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)
#### Post date: [January 13, 2022, 3:00am UTC](https://discourse.julialang.org/t/creating-animated-makie-plot-in-pluto/74464/3 "2022-01-13T03:00:55Z")

</div>

Thanks for the suggestion. I tried it and now I get the error

```julia
MethodError: Cannot `convert` an object of type Vector{Any} to an object of type Float64

```
