Hi, I’m very new to Julia and the plots package. I’d like to plot 2 ode solutions within the same gif. For example, say I’m solving the lorenz function and want to plot two solutions with different parameters in the same animation.
#lorenz solver
function simulate(params)
function lorenz(du, u, p, t)
du[1] = p[1]*(u[2]-u[1])
du[2] = u[1]*(p[2]-u[3]) - u[2]
du[3] = u[1]*u[2] - p[3]*u[3]
end
u0 = [1.; 5.; 10.]
tspan = (0, 100)
p = params
prob = ODEProblem(lorenz, u0, tspan, p)
sol = solve(prob)
return sol
end
#two different solutions
sol1 = simulate([10; 28; 8/3])
sol2 = simulate([5;32;10])
#animate
n = length(sol1.t)
plt = plot3d(1, xaxis = ("x" ,(-30, 30)), yaxis = ("y", (-30,30)), zaxis=("z", (0, 60)))
anim = @animate for i in 1:n
push!(plt, sol1[1,i], sol1[2,i], sol1[3,i])
end
gif(anim, "myGif.gif")
I can’t seem to figure out an elegant way to allow both solutions to be in the same gif. Please let me know of any ideas! Thank you in advance