Skip to content

Commit

Permalink
add keyword argument start_from to AnalysisCallback plot recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLampert committed Feb 1, 2024
1 parent 8946fea commit 7c547f1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ function pretty(name)
end

@recipe function f(cb::DiscreteCallback{Condition, Affect!}; what = (:integrals,),
label_extension = "",
label_extension = "", start_from = 1,
exclude = []) where {Condition, Affect! <: AnalysisCallback}
t = tstops(cb)
@assert length(t) > start_from "The keyword argument `start_from` needs to be smaller than the number of timesteps: $(length(t))"
subplot = 1
layout --> length(what)
if :integrals in what
Expand All @@ -200,7 +201,7 @@ end
title --> "change of invariants"
xguide --> "t"
yguide --> "change of invariants"
t, integral .- integral[1]
t[start_from:end], (integral .- integral[1])[start_from:end]
end
end
subplot += 1
Expand All @@ -215,7 +216,7 @@ end
title --> "errors"
xguide --> "t"
yguide --> "sum of errors"
t, dropdims(sum(err, dims = 1), dims = 1)
t[start_from:end], dropdims(sum(err, dims = 1), dims = 1)[start_from:end]
end
end
end
Expand Down

0 comments on commit 7c547f1

Please sign in to comment.