How to make plot window stay open when running a .jl script

First, please quote your code: this makes it easier to run your examples and help you.


As for your question: the problem is that you need Julia to stay alive for it to display the graph. There are two ways (that I know of):

  1. run your script like this:

    sh> julia -i plotex.jl
    

    this will make the REPL stay alive after having executed your file. You can look at your plot, and kill the REPL manually afterwards as usual, using for example Ctrl+d or exit().

  2. add readline() at the end of your script. This will make Julia wait until you press RET before it exits (and makes your plot disappear)

2 Likes