# Display animation created with Luxor in jupyter notebook

**URL:** <https://discourse.julialang.org/t/display-animation-created-with-luxor-in-jupyter-notebook/26839>\
**Category:** Visualization\
**Tags:** jupyter, luxor, animations\
**Created:** [July 26, 2019, 9:00am UTC](https://discourse.julialang.org/t/display-animation-created-with-luxor-in-jupyter-notebook/26839 "2019-07-26T09:00:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![karlroyen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karlroyen/32/9301_2.png) [@karlroyen](https://discourse.julialang.org/u/karlroyen)\
**Post date:** [July 26, 2019, 9:00am UTC](https://discourse.julialang.org/t/display-animation-created-with-luxor-in-jupyter-notebook/26839/1 "2019-07-26T09:00:02Z")

</div>

Can I display an animation created with Luxor in a jupyter notebook?

For example if I put something like the example code for animation

```julia
using Colors, Luxor
demo = Movie(400, 400, "test")

function backdrop(scene, framenumber)
    background("black")
end

function frame(scene, framenumber)
    sethue(Colors.HSV(framenumber, 1, 1))
    eased_n = scene.easingfunction(framenumber, 0, 1, scene.framerange.stop)
    circle(polar(100, -π/2 - (eased_n * 2π)), 80, :fill)
    text(string("frame $framenumber of $(scene.framerange.stop)"),
        Point(O.x, O.y-190),
        halign=:center)
    text(scene.opts,
        boxbottomcenter(BoundingBox()),
        halign=:center,
        valign=:bottom)
end

animate(demo, [
    Scene(demo, backdrop, 0:359),
    Scene(demo, frame, 0:359,
        easingfunction=easeinoutcubic,
        optarg="made with Julia")
    ],
    creategif=true,
    pathname="anim.gif")

```

in a cell, I would like the created animation to be displayed directly when the cell is executed (like it works for images).

As an (not really good) alternative option I also tried to display the gif in a markdown cell afterwards with

```julia
[alt text](anim.gif)

```

but that only shows a link with the alternate text. But at least if the link is clicked a new page opens where the animation is displayed. So the link seems to work.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [July 26, 2019, 1:02pm UTC](https://discourse.julialang.org/t/display-animation-created-with-luxor-in-jupyter-notebook/26839/2 "2019-07-26T13:02:25Z")

</div>

I don’t think the `animate()` function returns anything (apart from ‘true’ if successful), so nothing will be automatically displayed. It should be easy to include a link to a file, though. Do you need `!` characters somewhere?

(I rarely use Jupyter, sorry…)

---

<div class="post-metadata">

**Author:** ![karlroyen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karlroyen/32/9301_2.png) [@karlroyen](https://discourse.julialang.org/u/karlroyen)\
**Post date:** [July 27, 2019, 6:34am UTC](https://discourse.julialang.org/t/display-animation-created-with-luxor-in-jupyter-notebook/26839/3 "2019-07-27T06:34:26Z")

</div>

> [@cormullion](#):
>
> Do you need `!` characters somewhere?

Yes, thanks! With

```julia
![alt text](anim.gif)

```

it directly shows the animated gif.

However, it still would be better if there was some Julia method i could call which returns something that jupyter can display as animation directly. That way I wouldn’t need two different cells which need to be in sync.

Edit: Okay, I can use

```julia
display(MIME("text/html"), """<img src="anim.gif">""")

```

after the call to `animate` to directly display the created gif. It still would be nicer if IJulia could display the animation directly but I couldn’t find out how IJulia decides how to display the return value of a cell. I tried implementing `showable` and `display` for an array of `Scene`s, but that doesn’t seem to be sufficient.
