Skip to content

Commit

Permalink
feat: add plottable_indices
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Nov 7, 2024
1 parent c1200b6 commit b262f1f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/solutions/solution_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ function isdenseplot(sol)
sol.interp isa SensitivityInterpolation)
end

"""
$(TYPEDSIGNATURES)
Given the first element in a timeseries solution, return an `AbstractArray` of
indices that can be plotted as continuous variables. This is useful for systems
that store auxiliary variables in the state vector which are not meant to be
used for plotting.
"""
plottable_indices(x::AbstractArray) = 1:length(x)

@recipe function f(sol::AbstractTimeseriesSolution;
plot_analytic = false,
denseplot = isdenseplot(sol),
Expand All @@ -225,7 +235,7 @@ end
throw(ArgumentError("No analytic solution was found but `plot_analytic` was set to `true`."))
end

idxs = idxs === nothing ? (1:length(sol.u[1])) : idxs
idxs = idxs === nothing ? plottable_indices(sol.u[1]) : idxs
if !(idxs isa Union{Tuple, AbstractArray})
vars = interpret_vars([idxs], sol)
else
Expand Down

0 comments on commit b262f1f

Please sign in to comment.