Skip to content

Commit d7bc515

Browse files
Merge pull request #572 from SciML/plotrecipe_symbolic
Change the plot recipes to use the SymbolicIndexingInterface
2 parents 1ccfa8d + db52700 commit d7bc515

File tree

4 files changed

+144
-275
lines changed

4 files changed

+144
-275
lines changed

Diff for: src/integrator_interface.jl

+22-8
Original file line numberDiff line numberDiff line change
@@ -752,20 +752,19 @@ Base.length(iter::TimeChoiceIterator) = length(iter.ts)
752752
idxs = vars
753753
end
754754

755-
syms = getsyms(integrator)
756-
int_vars = interpret_vars(idxs, integrator.sol, syms)
757-
strs = cleansyms(syms)
755+
int_vars = interpret_vars(idxs, integrator.sol)
758756

759757
if denseplot
760758
# Generate the points from the plot from dense function
761-
plott = collect(range(integrator.tprev; step = integrator.t, length = plotdensity))
762-
plot_timeseries = integrator(plott)
759+
plott = collect(range(integrator.tprev, integrator.t; length = plotdensity))
763760
if plot_analytic
764761
plot_analytic_timeseries = [integrator.sol.prob.f.analytic(integrator.sol.prob.u0,
765762
integrator.sol.prob.p,
766763
t) for t in plott]
767764
end
768-
end # if not denseplot, we'll just get the values right from the integrator.
765+
else
766+
plott = nothing
767+
end
769768

770769
dims = length(int_vars[1])
771770
for var in int_vars
@@ -779,11 +778,18 @@ Base.length(iter::TimeChoiceIterator) = length(iter.ts)
779778
end
780779

781780
labels = String[]# Array{String, 2}(1, length(int_vars)*(1+plot_analytic))
781+
strs = String[]
782+
varsyms = variable_symbols(integrator)
783+
@show plott
784+
782785
for x in int_vars
783786
for j in 2:dims
784787
if denseplot
785-
push!(plot_vecs[j - 1],
786-
u_n(plot_timeseries, x[j], integrator.sol, plott, plot_timeseries))
788+
if (x[j] isa Integer && x[j] == 0) || isequal(x[j],getindepsym_defaultt(integrator))
789+
push!(plot_vecs[j - 1], plott)
790+
else
791+
push!(plot_vecs[j - 1], Vector(integrator(plott; idxs = x[j])))
792+
end
787793
else # just get values
788794
if x[j] == 0
789795
push!(plot_vecs[j - 1], integrator.t)
@@ -793,6 +799,14 @@ Base.length(iter::TimeChoiceIterator) = length(iter.ts)
793799
push!(plot_vecs[j - 1], integrator.u[x[j]])
794800
end
795801
end
802+
803+
if !isempty(varsyms) && x[j] isa Integer
804+
push!(strs, String(getname(varsyms[x[j]])))
805+
elseif hasname(x[j])
806+
push!(strs, String(getname(x[j])))
807+
else
808+
push!(strs, "u[$(x[j])]")
809+
end
796810
end
797811
add_labels!(labels, x, dims, integrator.sol, strs)
798812
end

0 commit comments

Comments
 (0)