You need to use gui()
to display the plot window.
In the REPL, objects that are returned are displayed. That's why anything without a ;
gets displayed (also matrices, vectors, etc.). When you go to a script, that's no longer true (which is why you don't need to use ;
). In Atom it's reading it in script mode, so you have to manually display things via display(obj)
, or if using plots you can just use gui()
.
To display things in the same plot window, you simply set reuse=true when setting the backend, i.e.
gr(reuse=true)
Note you can also add show=true
to make it automatically show when plots are made instead of having to call gui()
.
Then to do live plotting, just push the new values into the plot. The full code looks like this:
using Plots
gr(reuse=true)
p =plot([0;.1],[0;.2])
gui()
for i=2:10
push!(p,i*.1,randn())
gui()
sleep(.1) # To slow things down for show.
end
This answer should work with any backend. Note I switched to GR.jl since it tends to be faster
plotlyjs
Plots backend – spencerlyon2