Manual section on plotting from script incomplete?

Tutorial · Plots says

In a script, Julia does not do automatic displays (which is why ; is not necessary). However, if we would like to display our plots in a script, this means we just need to add the display call. For example:

display(plot(x, y))

However, as others have noted this isn’t enough for a plot window to actually get shown. For example, with

$ cat t.jl 
using Plots, Random

x = 1:10
y = rand(10,2)

display(plot(x,y))

on my Arch Linux system with 1.6.1 julia t.jl will not show a plot window. I need to add the -i option to fix it. This actually makes sense, as that will keep the julia process alive. So I’m wondering if the above doc section should not also mention that?

1 Like

Take a look to Output · Plots

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.

If you have any suggestion to the documentation, you can create a pull request (PR) in GitHub as follows.


Yes, I know that, but I’m still wondering if the docs are at fault here, or if there is something else going on. Should display(plot(...)) always show a window if called from a script without the -i option?

Sorry, I misunderstood your question; I thought you were asking about the docs, in which case I invite you to make your suggestions as a PR.

I don’t know if the -i option is necessary to display the window…