I have a fresh install of Julia(on Catalina), with Plots added via Pkg. Then I try to plot a simple line:
using Plots; println("imported")
x = 1:10; y = rand(10); # These are the plotting data
println("tryna plot"); plot(x, y); println("you see?")
Running this file via julia try.jl just prints out the two prints. (Although, it happily plots to GSKTerm from REPL).
My question is, why does it fail silently? Shouldn’t Julia tell me that it didn’t find any backends to complete plot(x,y)? Is it a design choice(in which case, where can I read more about it)?
Why not end with a non-zero exit code at least?
Edit: Of course above code will never display the plot, as ; suppresses it. But my initial attempts were without the ;, which was added for brevity. I shan’t fix the code above as it will take away from @Volker’s instructive comment.
It is not failing, the script exits and you do not have time to see the plot. Add a savefig("plot.png") and you will get the result in that file. Or else you need to pause the script, for example adding a read statement after plotting.
Indeed, it does show up in GKSTerm. So, what happens to the plot otherwise? It simply gets computed but not displayed huh?
Shouldn’t it get displayed due to plot(x,y) anyway, as that line returns the plot, and, as mentioned here
A Plot is only displayed when returned (a semicolon will suppress the return)
I appreciate your help, but I was using the semi-colons to cut down on the number of lines while also being able to ‘see’ whats going on. For example, the first println told me that using Plots takes an awful lot of time to happen(which still has me bewildered).