Makie recipe to plot ODESolution of DifferentialEquations.jl?

Related to this question.

Is there a recipe to plot the DiffEq solution components against time?

I tried

Makie.convert_arguments(sol::ODESolution) = (sol.t, [[v[1] for v in sol.u], [[v[2] for v in sol.u]]])

but it plots solution components against each other.

1 Like

There is none that is shipped in the package.

As there is none, I would really appreciate advice how to implement one, because the Makie docs on recipes are a bit confusing.

Maybe this GMT example is similar to what you want?

1 Like

Is there a recipe to plot the DiffEq solution components against time?

unsure is this what you want, here’s how I plotted for 4 degree of freedom system - the function rotor in mine returns SVector{4}(du1,du2,du3,du4)

prob = ODEProblem(rotor, u0, times, params)
sol1 = solve(prob, AutoVern7(Rodas5()), dt = .005)
T = range(0,8000,length=500)  
# for plotting time series for 3rd variable
GLMakie.plot(T, sol1(T)[3,:], xlim=(0,8000))

you also can try DynamicalSystems.ji’s trajectory function example
and interactive trajectory

I’m still confused how to pack it into a recipe.

You need something like this:
Makie.convert_arguments(p::Makie.PointBased, sol::ODESolution) = convert_arguments(p, sol.t, [[v[1] for v in sol.u], [[v[2] for v in sol.u]]])
Not sure if this will work, you have to supply a minimal working example.

We’re pretty close to pin down how Makie should do recipes in the future and then revamp the docs accordingly.

4 Likes