# Animation sine wave

**URL:** <https://discourse.julialang.org/t/animation-sine-wave/22797>\
**Category:** New to Julia\
**Created:** [April 5, 2019, 12:59pm UTC](https://discourse.julialang.org/t/animation-sine-wave/22797 "2019-04-05T12:59:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterB1](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@PeterB1](https://discourse.julialang.org/u/PeterB1)\
**Post date:** [April 5, 2019, 12:59pm UTC](https://discourse.julialang.org/t/animation-sine-wave/22797/1 "2019-04-05T12:59:10Z")

</div>

I try to do a simple animation of a travelling sine wave.  
My code is

using Pkg  
Pkg.add(“Plots”)  
using Plots  
plotly()  
p =zeros(1)  
plot(p)  
#println(p)  
n=10  
@gif for i=0:n  
push!(p, sin(i/5))  
plot!(p)  
#println(i, p)  
end

Why isn’t this working?  
The error code is

LoadError: MethodError: no method matching \_show(::IOStream, ::MIME{Symbol(“image/png”)}, ::Plots.Plot{Plots.PlotlyBackend})

Closest candidates are:

\_show(::IO, !Matched::MIME{Symbol(“text/html”)}, ::Plots.Plot) at C:\Users\Gebruiker.julia\packages\Plots\QYETN\src\output.jl:163

\_show(::IO, !Matched::MIME{Symbol(“text/plain”)}, ::Plots.Plot) at C:\Users\Gebruiker.julia\packages\Plots\QYETN\src\output.jl:204

\_show(::IO, !Matched::MIME{Symbol(“application/vnd.plotly.v1+json”)}, ::Plots.Plot{Plots.PlotlyBackend}) at C:\Users\Gebruiker.julia\packages\Plots\QYETN\src\backends\plotly.jl:857

…

in expression starting at D:\ScTEXa\Biblio\Programming\Julia\Tests\test3:9

show(::IOStream, ::MIME{Symbol(“image/png”)}, ::Plots.Plot{Plots.PlotlyBackend}) at output.jl:198

png(::Plots.Plot{Plots.PlotlyBackend}, ::String) at output.jl:8

frame(::Animation, ::Plots.Plot{Plots.PlotlyBackend}) at animation.jl:20

frame(::Animation) at animation.jl:18

macro expansion at animation.jl:144 [inlined]

macro expansion at test3:11 [inlined]

top-level scope at animation.jl:155

Thanks Peter

---

<div class="post-metadata">

**Author:** ![Fuzeq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fuzeq/32/49148_2.png) [@Fuzeq](https://discourse.julialang.org/u/Fuzeq)\
**Post date:** [May 15, 2023, 8:41pm UTC](https://discourse.julialang.org/t/animation-sine-wave/22797/2 "2023-05-15T20:41:14Z")

</div>

```julia
using Plots
gr()
n=100
p =zeros(n)
plot(legend=false, xlims=[0,n], ylims=[-1.1,1.1])
an = @animate for i in 1:n
    p[i] = sin(i/5)
    plot!(p[1:i], color=:black)
end
gif(an, "sine.gif", fps = 40)

```

![sine](https://global.discourse-cdn.com/julialang/original/3X/f/0/f0697c4cc06ad10d5b66ddeb552192825b4d6032.gif)
