From a5680c78bd49c0b6bcc506d45c2fede3300174cb Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 31 Dec 2023 16:42:23 -0500 Subject: [PATCH 1/3] Implement plotat for solution plot recipe This allows the user to specify the times to plot at when using the recipe. This makes it so you can better control the times even when just using the automated dense form. This is much better than interpolating and then plotting since it has all of the niceties like the automated labels. --- src/solutions/solution_interface.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/solutions/solution_interface.jl b/src/solutions/solution_interface.jl index 95b19417b..005d32cdc 100644 --- a/src/solutions/solution_interface.jl +++ b/src/solutions/solution_interface.jl @@ -169,7 +169,7 @@ DEFAULT_PLOT_FUNC(x, y, z) = (x, y, z) # For v0.5.2 bug (sol.prob isa AbstractDiscreteProblem ? max(1000, 100 * length(sol)) : max(1000, 10 * length(sol))) : - 1000 * sol.tslocation), + 1000 * sol.tslocation, plotat = nothing), tspan = nothing, vars = nothing, idxs = nothing) if vars !== nothing @@ -190,7 +190,7 @@ DEFAULT_PLOT_FUNC(x, y, z) = (x, y, z) # For v0.5.2 bug tscale = get(plotattributes, :xscale, :identity) plot_vecs, labels = diffeq_to_arrays(sol, plot_analytic, denseplot, - plotdensity, tspan, vars, tscale) + plotdensity, tspan, vars, tscale, plotat) tdir = sign(sol.t[end] - sol.t[1]) xflip --> tdir < 0 @@ -267,7 +267,7 @@ DEFAULT_PLOT_FUNC(x, y, z) = (x, y, z) # For v0.5.2 bug end function diffeq_to_arrays(sol, plot_analytic, denseplot, plotdensity, tspan, - vars, tscale) + vars, tscale, plott) if tspan === nothing if sol.tslocation == 0 end_idx = length(sol) @@ -287,7 +287,9 @@ function diffeq_to_arrays(sol, plot_analytic, denseplot, plotdensity, tspan, (start, stop, n) -> range(start; stop = stop, length = n) end - if denseplot + if plotat !== nothing + plott = plotat + elseif denseplot # Generate the points from the plot from dense function if tspan === nothing && !(sol isa AbstractAnalyticalSolution) plott = collect(densetspacer(sol.t[start_idx], sol.t[end_idx], plotdensity)) From f76e805d6ffdc6dd394104fda1574ca6c3bd5c40 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 31 Dec 2023 17:16:17 -0500 Subject: [PATCH 2/3] Fix test --- test/solution_interface.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/solution_interface.jl b/test/solution_interface.jl index ed8edb31b..1f7773084 100644 --- a/test/solution_interface.jl +++ b/test/solution_interface.jl @@ -21,7 +21,8 @@ end 10, # plotdensity ode.tspan, int_vars, - :identity) # tscale + :identity, + nothing) # tscale @test plot_vecs[2][:, 2] ≈ @. exp(-plot_vecs[1][:, 2]) end From f8b9af04ecd95eb90c523ecec8e61b4e43cfaca2 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 31 Dec 2023 17:58:18 -0500 Subject: [PATCH 3/3] typo --- src/solutions/solution_interface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solutions/solution_interface.jl b/src/solutions/solution_interface.jl index 005d32cdc..9faa3fe1f 100644 --- a/src/solutions/solution_interface.jl +++ b/src/solutions/solution_interface.jl @@ -267,7 +267,7 @@ DEFAULT_PLOT_FUNC(x, y, z) = (x, y, z) # For v0.5.2 bug end function diffeq_to_arrays(sol, plot_analytic, denseplot, plotdensity, tspan, - vars, tscale, plott) + vars, tscale, plotat) if tspan === nothing if sol.tslocation == 0 end_idx = length(sol)