Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement plotat for solution plot recipe #578

Merged
merged 3 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/solutions/solution_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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, plotat)
if tspan === nothing
if sol.tslocation == 0
end_idx = length(sol)
Expand All @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion test/solution_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down