How to get a plot to stay open?



How to get a plot to stay open? gui(), display(), and <plot_impl>(show=true) all cause plot to close immediately. Except for in Julia REPL, where plot stays open forever and does not respond to close command. Using v0.6.2 on Ubuntu

Edit: Minimum working example

using Plots
gr(show = true)
p1 = plot(1:10,1:10)

Edit2: Using Blink Atomshell with PlotlyJS works
Edit3: Minor formatting fixes


I’m assuming you are plotting from a julia script and using terminal to call julia script.jl.
The problem is once your execution is finished, julia exists and hence the plot also closes.
You can try adding read(STDIN, Char) after plot, or better at the end of the script. This will make the plot stay until you press enter.

I also have the similar problem; when I click close button it didn’t work. I usually do close("all") in REPL to close them. OR close(fig_num) can also be used.


neither close("all") nor close(:all) close the window


a minimal code snippet always helps with such questions. you’ve given us no idea, for example, of which of the many plotting packages you’re using.


Doesn’t gr(show = true) means that GR is used?


That was not in the original version of the message.


The code section is the minimum working example, which as @dpsanders says was added as an edit. This behavior is not specific to GR. With Plotly, extra plots are generated in browser. In this case two plots are generated even though there is only one plot() call. This behavior seems like a different issue.


How do you run this code? As mentioned above, you can run either from REPL, Juno or Jupyter and the plot will stay open whereas if you run from a script (typing julia script.jl in the terminal), the GUI will close as soon as Julia exits: this is not the recommended way to use Plots.

To close all window you can use closeall().


would Gtk.jl’s trick work?