# Makie - plot script returned without visualization window

**URL:** https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828
**Category:** Visualization
**Tags:** makie
**Created:** [April 22, 2021, 8:46pm UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828 "2021-04-22T20:46:26Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)
#### Post date: [April 22, 2021, 8:46pm UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828/1 "2021-04-22T20:46:26Z")

</div>

I see the documentation that it might be a problem of GLMakie building, but my build seems fine without any errors. I also tried `build GLMakie`, it looks fine.

this is my code for test:

```julia
using ModernGL

#using Makie
#using CairoMakie
using GLMakie

x = LinRange(0, 10, 100)
y = sin.(x)
fig = lines(x, y)

display(fig)

```

---

<div class="post-metadata">

### Author: ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)
#### Post date: [April 22, 2021, 9:23pm UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828/2 "2021-04-22T21:23:53Z")

</div>

NVM, I fixed this using this code.

```julia
#using ModernGL

using Makie
# using WGLMakie
# WGLMakie.activate!()
using GLMakie
GLMakie.activate!()

set_window_config!(;
    vsync = false,
    framerate = 30.0,
    float = false,
    pause_rendering = false,
    focus_on_show = false,
    decorated = true,
    title = "Makie"
)

function display3d()
#using CairoMakie
#using GLMakie

    x = LinRange(0, 10, 100)
    y = sin.(x)
    z = cos.(x)

    fig = lines(x, y, z)

    display(fig)
end

display3d()

```

---

<div class="post-metadata">

### Author: ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)
#### Post date: [April 26, 2021, 9:33pm UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828/3 "2021-04-26T21:33:51Z")

</div>

it is not working again with the same code…  
the window shows up for a few seconds, but closed after that. Nothing have showed up in the window.

---

<div class="post-metadata">

### Author: ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)
#### Post date: [April 27, 2021, 2:58am UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828/4 "2021-04-27T02:58:03Z")

</div>

If you add `sleep(15)` at the last line you may see the plot. What is happening is that the program is finishing, and when this happens julia exits. Because Makie takes many seconds in showing the first plot, Julia exits before you get to see the plot.

Depending on your use case, you could either pass a `-i` flag to julia, to make it launch the REPL after your script (`julia -i myscript.jl`) or add a `sleep(30)` at the end. However julia is not very well suited for script-based plotting due to the long time to first plot.

Also, you really don’t need the package Makie, ModernGL nor the line `GLMakie.activate!()`. GLMakie is enough.

---

<div class="post-metadata">

### Author: ![Audrius-St](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/audrius-st/32/24175_2.png) [@Audrius-St](https://discourse.julialang.org/u/Audrius-St)
#### Post date: [October 30, 2022, 11:12pm UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828/5 "2022-10-30T23:12:21Z")

</div>

To view Makie plots when running a Julia script,

I do the following

```julia
. . .

# 1st Makie plot display
display(fig_1)

# Prompt to input from terminal
print("Press any key to contnue. ") 
    
# Call the readline function
readline()

. . .

# 2nd Makie plot display
display(fig_2)

# Prompt to input from terminal
print("Press any key to contnue. ") 
    
# Call the readline function
readline()

. . . 

```

and so on.

It would be useful if Makie waited until a plot window was closed before continuing as does Matplotlib in Python.

---

<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: [October 31, 2022, 10:40am UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828/6 "2022-10-31T10:40:58Z")

</div>

you can use `wait(display(fig))` to wait until the window gets closed 😉

---

<div class="post-metadata">

### Author: ![Audrius-St](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/audrius-st/32/24175_2.png) [@Audrius-St](https://discourse.julialang.org/u/Audrius-St)
#### Post date: [October 31, 2022, 6:09pm UTC](https://discourse.julialang.org/t/makie-plot-script-returned-without-visualization-window/59828/7 "2022-10-31T18:09:18Z")

</div>

`wait(display(fig))` is what I needed to know. Thanks.
