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

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”

Were you able to figure this out?

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

No I never did figure it out.

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

1 Like

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.

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).