Skip to content

Commit 0a9e9bc

Browse files
Add keyword argument start_from to AnalysisCallback plot recipe (#87)
* add keyword argument start_from to AnalysisCallback plot recipe * format
1 parent ccb42cb commit 0a9e9bc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/visualization.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,10 @@ function pretty(name)
184184
end
185185

186186
@recipe function f(cb::DiscreteCallback{Condition, Affect!}; what = (:integrals,),
187-
label_extension = "",
187+
label_extension = "", start_from = 1,
188188
exclude = []) where {Condition, Affect! <: AnalysisCallback}
189189
t = tstops(cb)
190+
@assert length(t)>start_from "The keyword argument `start_from` needs to be smaller than the number of timesteps: $(length(t))"
190191
subplot = 1
191192
layout --> length(what)
192193
if :integrals in what
@@ -200,7 +201,7 @@ end
200201
title --> "change of invariants"
201202
xguide --> "t"
202203
yguide --> "change of invariants"
203-
t, integral .- integral[1]
204+
t[start_from:end], (integral .- integral[1])[start_from:end]
204205
end
205206
end
206207
subplot += 1
@@ -215,7 +216,7 @@ end
215216
title --> "errors"
216217
xguide --> "t"
217218
yguide --> "sum of errors"
218-
t, dropdims(sum(err, dims = 1), dims = 1)
219+
t[start_from:end], dropdims(sum(err, dims = 1), dims = 1)[start_from:end]
219220
end
220221
end
221222
end

0 commit comments

Comments
 (0)