using Plots;plotly()
begin
plot()
for i = 0:0.1:1
vline!([i], leg = :none)
sleep(0.01)
end
#plot!()
end
I want to the plot for for each iteration of the loop.How can I do it?
using Plots;plotly()
begin
plot()
for i = 0:0.1:1
vline!([i], leg = :none)
sleep(0.01)
end
#plot!()
end
I want to the plot for for each iteration of the loop.How can I do it?
This works fine for me:
begin
p = plot()
for i = 0:0.1:1
vline!(p, [i], leg = :none)
sleep(0.01)
end
p
end
If I understand OP correctly, he wants to show the plot in each iteration? I.e. this:
p = plot()
for i = 0:0.1:1
vline!(p, [i], leg = :none)
sleep(0.1)
display(p)
end
p
(note the display
call), which works fine for me in Juno, but not in Pluto for some reason.
In that case I would probably take advantage of Pluto’s reactive nature and create a Slider(0:0.1:1)
via PlutoUI and then view the plot that way…
T = 0:0.1:1
@bind N Slider(eachindex(T))
let
p = plot()
for i = T[1:N]
vline!(p, [i], leg = :none)
end
p
end
That is a great of doing the plots, but I want to plot live data. The solution here does my job what if I want to display the plots before the all the loops are computed ?
A simple use case is gradient descent. We want to plot live data of loss v/s epoch of the model being trained. Based on the live graph we can decide whether to continue or stop the rest of the computation.
Is there any way I can do it ?
I wrote a minimal demo about this once:
https://github.com/fonsp/disorganised-mess/blob/master/epoch.jl