# Animation using frames in Dash for Julia

**URL:** <https://discourse.julialang.org/t/animation-using-frames-in-dash-for-julia/70254>\
**Category:** Visualization\
**Tags:** visualization, plotlyjs, dash, animations\
**Created:** [October 23, 2021, 6:35am UTC](https://discourse.julialang.org/t/animation-using-frames-in-dash-for-julia/70254 "2021-10-23T06:35:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![valeroc](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@valeroc](https://discourse.julialang.org/u/valeroc)\
**Post date:** [October 23, 2021, 6:35am UTC](https://discourse.julialang.org/t/animation-using-frames-in-dash-for-julia/70254/1 "2021-10-23T06:35:17Z")

</div>

Hi,

I have been trying to do animation in Dash for Julia using frames (see the Simple Play Button Demo at [Intro to animations in Python](https://plotly.com/python/animations/)) . I managed to make that demo work for Dash in Python but after translating it to Dash for Julia I had no luck. The code is as follows:

````julia
using Dash, DashHtmlComponents, DashCoreComponents

app = dash()

frames = [
    Dict(:data => [Dict(:x => [1, 2], :y => [1, 2])]),
    Dict(:data => [Dict(:x => [1, 4], :y => [1, 4])]),
    Dict(:data => [Dict(:x => [3, 4], :y => [3, 4])]),
]

play_button = [
    Dict(
        :type => "buttons",
        :buttons => [Dict(:label => "Play", :method => "animate", :args => [nothing])],
    ),
]

layout = Dict(
    :xaxis => Dict(:range => [0, 5], :autorange => false),
    :yaxis => Dict(:range => [0, 5], :autorange => false),
    :updatemenus => [
        Dict(
            :type => "buttons",
            :buttons => [Dict(:label => "Play", :method => "animate", :args => [nothing])],
        ),
    ],
)

f0 = [Dict(:x => [0, 1], :y => [0, 1])]
fig = Dict(:data => f0, :layout => layout)
app.layout = html_div([html_h4("Animation"), dcc_graph(id = "graph1", figure = fig)])

run_server(app, "0.0.0.0", debug = true)```

````

Hopefully someone will be able to see something I am missing

Thanks!

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [October 23, 2021, 11:30am UTC](https://discourse.julialang.org/t/animation-using-frames-in-dash-for-julia/70254/2 "2021-10-23T11:30:22Z")

</div>

I have no working experience with Dash, but comparing with animation in PlotlyJS [PlotlyJS.jl animation - #3 by empet](https://discourse.julialang.org/t/plotlyjs-jl-animation/70058/3), I think that your app doesn’t work because you didn’t pass the frames to the fig definition.

---

<div class="post-metadata">

**Author:** ![valeroc](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@valeroc](https://discourse.julialang.org/u/valeroc)\
**Post date:** [October 23, 2021, 12:32pm UTC](https://discourse.julialang.org/t/animation-using-frames-in-dash-for-julia/70254/3 "2021-10-23T12:32:23Z")

</div>

Hi empet. Thanks for your reply. You are correct, I forgot to pass the frames to the figure. It’s working!! Thanks!
