I recently revisited how to do on-the-fly visualisation in an IJulia notebook, i.e., plotting results while the computation is still running. This was discussed a while back in Google groups link
I’ve tried the same scheme with Plots.jl
with Plotly backend, and I am thrilled that this still works. (Julia 0.5.1pre). Below is the code for anybody interested.
But my key issue back then and still now is: why does it need to be so complicated? I.e. why can I not simply write
x = linspace(0, 2*pi, 100) |> collect
dt, nsteps = 0.03, 300
for n = 1:nsteps
plot(x, sin(x - dt*n))
end
Is there a fundamental barrier? I would really appreciate this functionality not just for my own research but also for teaching with Julia. (I can’t promise but I might even be able to find some funding to get it implemented.)
Here is the promised code now:
CELL 1
using Reactive, Interact, Plots
Plots.plotlyjs()
function myplot(data)
Plots.plot(data[1], data[2], xlims=(0, 2*pi), ylims=(-1.2,1.2))
end
x = linspace(0, 2*pi, 100) |> collect
myinput = Signal((x, sin(x)))
lift(myplot, my input)
CELL 2
dt, nsteps = 0.03, 300
for n = 1:nsteps
push!(myinput, (x, sin(x - n*dt)))
end