From 0a9e9bc4d29e7b62cc5ce580266b5ce596b64a91 Mon Sep 17 00:00:00 2001 From: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:48:41 +0100 Subject: [PATCH] Add keyword argument `start_from` to `AnalysisCallback` plot recipe (#87) * add keyword argument start_from to AnalysisCallback plot recipe * format --- src/visualization.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/visualization.jl b/src/visualization.jl index 4d72c9a8..1f29df24 100644 --- a/src/visualization.jl +++ b/src/visualization.jl @@ -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 @@ -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 @@ -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