On-the-fly Animation in IJulia Notebooks

I would like to do updating like this for a histogram; the difficulty there is that I need to give the coordinates of the boxes. Any hints for that case? I.e., how can I extract those coordinates?

Can’t you just specify the edges yourself and pass them as a vector to bins? Then you are also certain they won’t jump around in your animation.
If you want to calculate them from the data, the current algorithm in Plots does linspace(extrema(x)..., bins + 1), though it is likely to change to StatsBase.fit(StatsBase.Histogram, x, nbins = bins).edges[1] in the near future, with bins having a default value of 30.

The problem is rather that of then calculating the actual polygons ( (x, y) pairs) to pass in to update the drawing, as far as I can see.

1 Like

You’re right. I was too fast on the trigger here.

Try

using Plots
default(show=:ijulia)
bins = collect(-3:3); ylims = (0, 400)
p = histogram(randn(1000), bins = bins, ylims = ylims)

for i in 1:10
    h = histogram(randn(1000), bins = bins, ylims = ylims);
    p[1] = h.series_list[1][:x], h.series_list[1][:y]
    sleep(0.2)
    p
end

Of course this suffers from the overhead of calling histogram

2 Likes

So interesting!