Plotting from within a loop using GR?

question
plotting

#1

The following doesn’t produce any output using Juno and v0.6 of Julia:

histogram(randn(10))

for i = 1:10
	histogram!(randn(10))
end

why is that?


#2

Don’t you need to add TO an existing plot?

p = histogram(randn(10))

for i in 1:10 
  histogram!(p, randn(10))
end

p

yields


#3

GR:

using GR
inline("atom")
for i in 1:100
  histogram(randn(10000))
end

Plots + gr():

using Plots
gr()
for i in 1:100
  display(histogram(randn(10000)))
end

#5

If you plot from within a loop using Plots, I believe you have to call the function gui() in the end of the loop for the results to be displayed.


#6

If you add to a plot within a loop, no plot object is returned and thus nothing is shown. Another alternative to the above advices is returning the current plot object with current() after the loop:

histogram(randn(10))
for i in 1:10
    histogram!(randn(10))
end
current()

#7

maybe this discussion helps: