# Why Plots standalone window closed automatically and load slowly?

**URL:** https://discourse.julialang.org/t/why-plots-standalone-window-closed-automatically-and-load-slowly/75471
**Category:** New to Julia
**Tags:** question
**Created:** [January 30, 2022, 3:56pm UTC](https://discourse.julialang.org/t/why-plots-standalone-window-closed-automatically-and-load-slowly/75471 "2022-01-30T15:56:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![varvir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/varvir/32/33328_2.png) [@varvir](https://discourse.julialang.org/u/varvir)
#### Post date: [January 30, 2022, 3:56pm UTC](https://discourse.julialang.org/t/why-plots-standalone-window-closed-automatically-and-load-slowly/75471/1 "2022-01-30T15:56:42Z")

</div>

I play the [tutorial](https://docs.juliaplots.org/stable/tutorial/) of Plots package.

```julia
using Plots
x = 1:10; y = rand(10); # These are the plotting data
p1 = plot(x, y)
gui(p1) # dispaly(p1), default(show=true), plot(x,y,show=true) 

```

I can plot this in Julia REPL mode. But, I can’t plot this by running the script file in command line.  
Plot window closed automatically. One more thing, Why throwing plot window is so slow? It tooks quite 2~3 seconds.

---

<div class="post-metadata">

### Author: ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)
#### Post date: [January 30, 2022, 4:22pm UTC](https://discourse.julialang.org/t/why-plots-standalone-window-closed-automatically-and-load-slowly/75471/2 "2022-01-30T16:22:24Z")

</div>

1. Your Julia process probably ended, taking the plot window with it
2. Compilation etc, commonly known as “time to first plot”

---

<div class="post-metadata">

### Author: ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)
#### Post date: [January 30, 2022, 6:29pm UTC](https://discourse.julialang.org/t/why-plots-standalone-window-closed-automatically-and-load-slowly/75471/3 "2022-01-30T18:29:36Z")

</div>

When Julia closes, it takes any process it owns with it, like those plot windows. One solution is to use `savefig("plot.pdf")` and use an external viewer. But the real solution to both your problems is to not use a run-script-and-quit workflow. Julia is poorly suited to it.

Just fire up a repl, `include("script.jl")` and repeat. You’ll notice the plotting (and almost everything else) is faster the second time around, because then it has compiled all those methods.
