Skip to content

Commit d3c6f8e

Browse files
plot variable dimensions per series
Fixes #591
1 parent ebb9ebe commit d3c6f8e

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/solutions/solution_interface.jl

+9-14
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ DEFAULT_PLOT_FUNC(x,y,z) = (x,y,z) # For v0.5.2 bug
6161
denseplot = (sol.dense ||
6262
typeof(sol.prob) <: AbstractDiscreteProblem) &&
6363
!(typeof(sol) <: AbstractRODESolution) &&
64-
!(hasfield(typeof(sol),:interp) &&
64+
!(hasfield(typeof(sol),:interp) &&
6565
typeof(sol.interp) <: SensitivityInterpolation),
6666
plotdensity = min(Int(1e5),sol.tslocation==0 ?
6767
(typeof(sol.prob) <: AbstractDiscreteProblem ?
@@ -95,10 +95,10 @@ DEFAULT_PLOT_FUNC(x,y,z) = (x,y,z) # For v0.5.2 bug
9595
if getindex.(int_vars,1) == zeros(length(int_vars)) || getindex.(int_vars,2) == zeros(length(int_vars))
9696
xguide --> "t"
9797
end
98-
if length(int_vars[1]) >= 3 && getindex.(int_vars,3) == zeros(length(int_vars))
98+
if all(x->length(x) >= 3 && x[4] == 0,int_vars)
9999
yguide --> "t"
100100
end
101-
if length(int_vars[1]) >= 4 && getindex.(int_vars,4) == zeros(length(int_vars))
101+
if all(x->length(x) >= 4 && x[4] == 0,int_vars)
102102
zguide --> "t"
103103
end
104104

@@ -236,12 +236,7 @@ function diffeq_to_arrays(sol,plot_analytic,denseplot,plotdensity,tspan,axis_saf
236236
end
237237
end
238238

239-
dims = length(int_vars[1])
240-
for var in int_vars
241-
@assert length(var) == dims
242-
end
243-
# Should check that all have the same dims!
244-
plot_vecs,labels = solplot_vecs_and_labels(dims,int_vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries,strs)
239+
plot_vecs,labels = solplot_vecs_and_labels(int_vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries,strs)
245240
end
246241

247242
function interpret_vars(vars,sol,syms)
@@ -420,12 +415,12 @@ function u_n(timeseries::AbstractArray, n::Int,sol,plott,plot_timeseries)
420415
end
421416
end
422417

423-
function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries,strs)
418+
function solplot_vecs_and_labels(vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries,strs)
424419
plot_vecs = []
425420
labels = String[]
426421
for x in vars
427422
tmp = []
428-
for j in 2:dims
423+
for j in 2:length(x)
429424
push!(tmp, u_n(plot_timeseries, x[j],sol,plott,plot_timeseries))
430425
end
431426

@@ -440,7 +435,7 @@ function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analyt
440435
end
441436
push!(plot_vecs[i],tmp[i])
442437
end
443-
add_labels!(labels,x,dims,sol,strs)
438+
add_labels!(labels,x,length(x),sol,strs)
444439
end
445440

446441

@@ -449,7 +444,7 @@ function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analyt
449444
analytic_plot_vecs = []
450445
for x in vars
451446
tmp = []
452-
for j in 2:dims
447+
for j in 2:length(x)
453448
push!(tmp, u_n(plot_analytic_timeseries, x[j],sol,plott,plot_analytic_timeseries))
454449
end
455450
f = x[1]
@@ -458,7 +453,7 @@ function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analyt
458453
for i in eachindex(tmp)
459454
push!(plot_vecs[i],tmp[i])
460455
end
461-
add_analytic_labels!(labels,x,dims,sol,strs)
456+
add_analytic_labels!(labels,x,length(x),sol,strs)
462457
end
463458
end
464459
plot_vecs = [hcat(x...) for x in plot_vecs]

0 commit comments

Comments
 (0)