Sorry I’m not set up to do that right now, it was a while ago and the examples I do have are definately maximal. I remember discussing with @ChrisRackauckas somewhere but neither of us succeeded getting it working.
using OrdinaryDiffEq
using Unitful: m, s
using Plots, UnitfulRecipes
const g = 9.81m/s^2
function traj2(u, p, t)
x,y,vx,vy = u
[vx,
vy,
0.0 * g, # make dimensionally consistent
-g]
end
tspan = (0.0s, 30.0s)
u₀ = [0.0m, 0.0m, 100m/s, 100m/s]
sol = solve(ODEProblem(traj2, u₀, tspan), Tsit5())
plot(sol[1,:],sol[2,:]) # works
plot(sol) # does not work
#-> ERROR: DimensionError: m and m s^-1 are not dimensionally compatible.
I don’t think its a good idea for either Plots.jl or RecipesBase to depend on Unitful. I think the only reasonable candidate to include UnitfulRecipes would be Unitful.jl.
i.e. only plotting columns which have the same units.
The most elegant would be if the units were moved to the legend and the axis would not have any units. But that’s maybe more than @jw3126 signed up for.
Thanks for registering this, it’s just what I needed. I’ve been using UnitfulPlots for some debug plotting and loading it manually but it’s much better to have a registered package for this.