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

Hi, my problem is as described here.

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

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.

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.

1 Like

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.

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?

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.

if you start your IDE anew and run in that?

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.

this happens in julia script.jl every time

Add

ENV[“GKSwstype”]=“nul”

To suppress the window.

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.

ENV["GKSwstype"] = "nul"

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