Je travaille de la following example et échoue lamentablementComment animer un changement d'histogramme dans Plots.jl?
# initialize the attractor
n = 1500
dt = 0.02
σ, ρ, β = 10., 28., 8/3
x, y, z = 1., 1., 1.
# initialize a 3D plot with 1 empty series
plt = path3d(1, xlim=(-25,25), ylim=(-25,25), zlim=(0,50),
xlab = "x", ylab = "y", zlab = "z",
title = "Lorenz Attractor", marker = 1)
# build an animated gif, saving every 10th frame
@gif for i=1:n
dx = σ*(y - x) ; x += dt * dx
dy = x*(ρ - z) - y ; y += dt * dy
dz = x*y - β*z ; z += dt * dz
push!(plt, x, y, z)
end every 10
J'ai des simulations où je veux calculer et tracer un histogramme de temps en temps, puis animer tous les histogrammes. Voilà ce que j'ai à ce jour comme un exemple de jouet:
using Distributions
using Plots
Plots.gr()
p = rand(Normal(0,1), 10000)
myplot = Plots. histogram(p)
savefig("initial.png")
anim = @animate for i=1:10
p = rand(Normal(0,1), 10000)
push!(myplot, Plots.histogram(p))
end
gif(anim, "mygif.gif", fps = 1)
Comme vous pouvez le constater, je ne suis pas vraiment comment fonctionne cette chose @animate et suis juste deviner la syntaxe ici. Je sais que je pourrais sauver un tas de PNG et animer plus tard, mais je veux essayer de cette façon.
Vous êtes relotissement de même histogramme et plus - qui ne sera pas creat une animation. Au lieu de cela, appelez 'histogram (rnorm (10000))' dans la boucle. –
Il est assez bien expliqué dans la documentation https://juliaplots.github.io/animations/ et les liens qu'il contient. – skleinbo
@ MichaelK.Borregaard fixe –