Plotting DifferentialEquations.jl solutions, re-indexing

Hi there, I am solving a system of differential equations using Differential equations.jl, and have the following result:
image
I would like to only plot the solution when it has stabilised (from 5 seconds onwards). I have been using plot(sol, xlims=(5.0,10.0)), which yields
image
but I am wondering if there is a way to re-index so that what used to be t=5 is now t=0 so that the x axis starts at zero instead of 5.

Thanks!

n=12  #set n such that sol.t[n]=5
plot(sol.t[n:end], sol.u[n:end], xlims=(sol.t[1], sol.t[end]))

You can pass a tspan to the plot. plot(sol,tspan=(5,10))

Is OP just looking for a change of variable:
t' = t .- 5 ?
Then, it should suffice to plot:

plot(sol.t .- 5, sol.u, xlims=(0, 5))

?

It’s not quite clear what he wants. I supposed that he intend to illustrate that the solution stabilizes starting from a time t’>0, and wanted to plot that solution above the integration time of the general solution, i.e. xlims=(sol.t[1], sol.t[end]). But I’m not sure…

*she

Thank you for your replies, I used the following workaround:

n = 1
for t in sol.t
    if t>10
        break
    end
    n+=1
end

x= sol.t[n:end] .- sol.t[n]
y = sol[systemic_circulation.source.Δp][n:end]

plot(x,y)

The question seems to be resolved, but just in case someone is in a similar situation and is looking for alternatives:

To deal with a transient time in some simulation, I usually use something like this:

# Define system of equation 
function f(du, u, p, t)
    du[1] = -u[1]
end

# Parameter for system (in this case there are none)
p = []

# Initial conditions
u0 = [1]

# Time points to integrate
times = 0:0.01:8

# Transient time
transient = 1

# Define ODE problem
prob = ODEProblem(
    f,                                      # system to integrate
    u0,                                     # initial conditions
    (times[1], times[end] + transient),     # time bounds to integrate in
    p                                       # parameters for the system
)

# Solve problem
sol = solve(
    prob,                           # problem to solve for
    saveat = times .+ transient     # times to get an answer for, but shifted by the transient time
    )

# Plot trajectories
plot(sol)

Someone, please feel free to correct me if this is an unnatural or inefficient way of doing things!

That is fine