I would like to create multiple plots in a loop within Pluto. The question is related to Plot inside a loop again[, but now in Pluto].
This works as expected in Jupyter, but not in Pluto.
using Plots
for i in 1:3
display(plot(rand(10)))
end
Is it possible to do the same in Pluto? Is this related to the Multiple outputs and inputs per cell?
Keep in mind that I am new to Pluto (and Julia) and the answer might be obvious.
Do you want to have separate plots or multiple lines in the same plot?
Sorry, I was not clear enough. I want separate plots.
The easiest way is to make an array of plots!
plots = [plot(rand(100)) for i=1:3]
2 Likes
Yes.
You can do it in Ploto by
plot((plot(rand(100)) for i=1:3)...;
size = default(:size) .* (1, 3), layout = (3, 1), left_margin = 5Plots.mm)
or
let
n = 3
PP = []
for i in 1:n
P = plot(rand(100))
push!(PP, P)
end
plot(PP...; size = default(:size) .* (1, n), layout = (n, 1), left_margin = 5Plots.mm)
end
1 Like
This is exactly what I was looking for. Thanks, @genkuroki.