# How do I wait for a Plots.jl window to be closed?

**URL:** <https://discourse.julialang.org/t/how-do-i-wait-for-a-plots-jl-window-to-be-closed/80122>\
**Category:** General Usage\
**Tags:** plots, gr, gui\
**Created:** [April 27, 2022, 10:48am UTC](https://discourse.julialang.org/t/how-do-i-wait-for-a-plots-jl-window-to-be-closed/80122 "2022-04-27T10:48:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [April 27, 2022, 10:48am UTC](https://discourse.julialang.org/t/how-do-i-wait-for-a-plots-jl-window-to-be-closed/80122/1 "2022-04-27T10:48:09Z")

</div>

Is there something similar to `plt.show(block=true)` from matplotlib in Plots.jl.  
I would prefer a solution for the GR backend.  
Maybe a call which is waiting for all windows / gui threads to be closed?

```julia
using Plots
p=plot(rand(10));
gui(p)
# somehow wait here for the gui to be closed
println("everything is closed")

```

---

<div class="post-metadata">

**Author:** ![baandersen](https://avatars.discourse-cdn.com/v4/letter/b/d2c977/32.png) [@baandersen](https://discourse.julialang.org/u/baandersen)\
**Post date:** [April 27, 2022, 3:01pm UTC](https://discourse.julialang.org/t/how-do-i-wait-for-a-plots-jl-window-to-be-closed/80122/2 "2022-04-27T15:01:33Z")

</div>

I do it like this (in GR)

```julia
using Plots
f(x) = x^2
x = collect(-10:10)
y = f.(x)
println(y)
p = plot(x, y, label=false, lw=1.0)
title!("f(x) = x^2")
display(p)
println("\npress enter to close plot")
readline()

```

---

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [April 27, 2022, 4:01pm UTC](https://discourse.julialang.org/t/how-do-i-wait-for-a-plots-jl-window-to-be-closed/80122/3 "2022-04-27T16:01:23Z")

</div>

This is a nice solution when the terminal is available. In my case a background process is started to execute the Julia code. Therefore I don’t have access to terminal inputs such as readline.
