Hey guys! I need to understand why this does not plot inside a for loop but does plot ok outside:
using Distributions, StatsPlots
dists = Iterators.product(0:1:2, 0:0.2:1) |> collect
for i in dists
plot!(Normal(i[1], i[2])) # also tried with plot() and also tried instantiating a plot() before the loop
end
Testing current() it seems to display only the final result after the loop, but not the intermediate plot updates, which can be of interest to visualize animations with some delay between plots:
plot()
for i in 1:5
sleep(0.5)
display(plot!(rand(10)))
end
Yes sorry I read this as the classic “I’m plotting in a loop and can’t see the output” issue, for intermediate plots indeed display is the way to go