Why doesn’t the following work:
using Plots
pyplot()
p=plot(layout=2)
for i = 1:2
plot!(p,rand(10),subplot=i)
end
while the following does work:
using Plots
pyplot()
p=plot(layout=2)
plot!(p,rand(10),subplot=1)
plot!(p,rand(10),subplot=2)
Why doesn’t the following work:
using Plots
pyplot()
p=plot(layout=2)
for i = 1:2
plot!(p,rand(10),subplot=i)
end
while the following does work:
using Plots
pyplot()
p=plot(layout=2)
plot!(p,rand(10),subplot=1)
plot!(p,rand(10),subplot=2)
Because for
loops in julia do not return the value. A plot is produced when a Plot
object is returned to the console (which implicitly calls display
in Julia). So just typing p
after your first code should work.
Thanks!