# Plot window showing up when run from terminal in Plots.jl

**URL:** <https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428>\
**Category:** General Usage\
**Created:** [October 15, 2020, 1:36pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428 "2020-10-15T13:36:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 15, 2020, 1:36pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/1 "2020-10-15T13:36:08Z")

</div>

Hi, my problem is as described [here](https://stackoverflow.com/questions/64371677/plot-window-showing-up-when-run-from-terminal-in-plots-jl).

I’m using Plots.jl with the default backend to plot an image and save the figure.

```julia
using Plots: plot, savefig
plot(rangex,rangey,some_image,xticks,yticks,...);
savefig("name.jpg");

```

this works perfectly fine with Juno IDE on Windows. But my final code is expected to run in the terminal. When I try to run the same code in terminal it becomes super slow and in each plot I see a GKS QtTerm window appear and disappear for a moment. Is there a way to disable this window?

**EDIT:** Here I did some tests about runtime, and I used 100 iterations of plot() function.

**In Atom Juno:**  
starting julia + loading libraries & functions took about **36s**  
doing 100 plot iterations took about **55s**  
total of **91** seconds.

**In Windows cmd:**  
starting julia + loading libraries & functions took about **21s**  
doing 100 plot iterations took about **284** seconds  
total of **305** seconds.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 15, 2020, 1:46pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/2 "2020-10-15T13:46:02Z")

</div>

```julia
plot(...);

```

> **A Plot is only displayed when returned** (a semicolon will suppress the return), or if explicitly displayed with `display(plt)` , `gui()` , or by adding `show = true` to your plot command.

---

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 15, 2020, 1:50pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/3 "2020-10-15T13:50:17Z")

</div>

I’m using the semicolon, and additionally, I just tried the` show = false` parameter in plot() function. however, the window still flashes when ran from the terminal.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 15, 2020, 1:53pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/4 "2020-10-15T13:53:09Z")

</div>

not sure, I don’t see it on Linux (maybe my windows manager is playing with me).

Notice this shouldn’t make your code slow, 80 seconds is because you’re running a flesh session of Julia right?

---

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 15, 2020, 2:00pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/5 "2020-10-15T14:00:04Z")

</div>

maybe it is just a windows issue. I directly run the code from the windows command line

> cmd \> julia.exe mycode.jl

In my code, I use a for loop and I call plot() function inside this loop. If it was to compile libraries or functions in the first iteration, I would totally understand. But it doesn’t seem like that, and it is slow on every iteration.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 15, 2020, 2:01pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/6 "2020-10-15T14:01:59Z")

</div>

if you start your IDE anew and run in that?

---

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 15, 2020, 2:12pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/7 "2020-10-15T14:12:44Z")

</div>

starting the IDE and getting the libraries ready takes about 70 seconds. But I do @time only when the iterations start, after the libraries are loaded, so the terminal adds up another 80 seconds to this time.

EDIT: I will clarify the runtimes after doing some tests and add them to the post.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 15, 2020, 2:25pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/8 "2020-10-15T14:25:30Z")

</div>

> [@libensvivit](#):
>
> getting the libraries ready takes about 70 seconds

this happens in `julia script.jl` every time

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 15, 2020, 2:38pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/9 "2020-10-15T14:38:19Z")

</div>

Add

```julia
ENV[“GKSwstype”]=“nul”

```

To suppress the window.

---

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 15, 2020, 2:47pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/10 "2020-10-15T14:47:53Z")

</div>

Now I’m getting

> GKS: invalid workstation type (null)

in the terminal, the window still appears, it works just fine but as slow as before.

---

<div class="post-metadata">

**Author:** ![libensvivit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libensvivit/32/19006_2.png) [@libensvivit](https://discourse.julialang.org/u/libensvivit)\
**Post date:** [October 15, 2020, 3:03pm UTC](https://discourse.julialang.org/t/plot-window-showing-up-when-run-from-terminal-in-plots-jl/48428/11 "2020-10-15T15:03:50Z")

</div>

`ENV["GKSwstype"] = "nul"`

solved my problem! And it is not “null” as I tried before, it is “nul” 🙂  
Thank you so much.
