# Makie does not display when mesh function is called in a loop

**URL:** <https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983>\
**Category:** Visualization\
**Created:** [March 14, 2020, 7:01pm UTC](https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983 "2020-03-14T19:01:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianguenter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brianguenter/32/29519_2.png) [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Post date:** [March 14, 2020, 7:01pm UTC](https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983/1 "2020-03-14T19:01:25Z")

</div>

I wrote a Makie function to draw several meshes in the same window but couldn’t get anything to display. Eventually simplified to the problem to this: if the Makie.mesh! function is called in a loop nothing displays, even if the function is only called once. If the loop is unrolled and changed to multiple calls to Makie.mesh! everything displays fine. Anybody know what is happening?

Here’s a simple example that demonstrates this:

This function displays a colored tetrahedron:

function makiemeshexample5()  
points = [(0,0,0), (1,0,2),(2,1,0),(0,2,1)]  
color = [:red, :green, :blue, :yellow]

```
# indices interpreted as triangles (every 3 sequential indices)
indices = [1 2 3; 1 3 4; 1 4 2; 2 3 4]
Makie.mesh!(points, indices, color = color)

```

end

The following function doesn’t display anything. No Makie window pops up, no error messages, nothing. Function just returns immediately. Even though the Makie.mesh! function is being called just once, exactly as in the first function.

function makiemeshexample5()  
points = [(0,0,0), (1,0,2),(2,1,0),(0,2,1)]  
color = [:red, :green, :blue, :yellow]

```
# indices interpreted as triangles (every 3 sequential indices)
indices = [1 2 3; 1 3 4; 1 4 2; 2 3 4]
for i in 1:1
      Makie.mesh!(points, indices, color = color)
end

```

end

version info:

Makie v0.9.5

Julia Version 1.3.0  
Commit 46ce4d7933 (2019-11-26 06:09 UTC)  
Platform Info:  
OS: Linux (x86\_64-pc-linux-gnu)  
CPU: AMD EPYC 7702P 64-Core Processor  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-6.0.1 (ORCJIT, znver1)  
Environment:  
JULIA\_NUM\_THREADS = 64  
JULIA\_EDITOR = “/usr/share/code/code”

---

<div class="post-metadata">

**Author:** ![Uroc327](https://avatars.discourse-cdn.com/v4/letter/u/eb8c5e/32.png) [@Uroc327](https://discourse.julialang.org/u/Uroc327)\
**Post date:** [January 11, 2021, 8:52pm UTC](https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983/2 "2021-01-11T20:52:16Z")

</div>

Were you able to figure this out?

I seem to have the same problem with `surface` and `scatter`.

---

<div class="post-metadata">

**Author:** ![brianguenter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brianguenter/32/29519_2.png) [@brianguenter](https://discourse.julialang.org/u/brianguenter)\
**Post date:** [January 11, 2021, 9:02pm UTC](https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983/3 "2021-01-11T21:02:30Z")

</div>

No I never did figure it out.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 12, 2021, 10:39am UTC](https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983/4 "2021-01-12T10:39:21Z")

</div>

You have to call `display(scene)`.  
You may want to take a look at the animation tutorial:  
[http://makie.juliaplots.org/dev/animation.html](http://makie.juliaplots.org/dev/animation.html)

---

<div class="post-metadata">

**Author:** ![Uroc327](https://avatars.discourse-cdn.com/v4/letter/u/eb8c5e/32.png) [@Uroc327](https://discourse.julialang.org/u/Uroc327)\
**Post date:** [January 14, 2021, 6:18pm UTC](https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983/5 "2021-01-14T18:18:10Z")

</div>

Thank you for the response, though I am not sure, if I actually got it.  
This is not about animation. I just want to plot ordinary `surface`/`scatter`/… plot. Also, what is `scene` in your answer? I am unable to find a reference to it in the example from the first post as well as in the documentation you linked.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 14, 2021, 8:16pm UTC](https://discourse.julialang.org/t/makie-does-not-display-when-mesh-function-is-called-in-a-loop/35983/6 "2021-01-14T20:16:20Z")

</div>

it’s `Figure` now, but the principle is the same. Plot to the figure and `display` the figure when you want to see it (or just return it and display will be called implicitly by the REPL, Vscode, whatever).
