Why Plots standalone window closed automatically and load slowly?

I play the tutorial of Plots package.

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.

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

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.

1 Like