Skip to content

Commit

Permalink
fix plots
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Feb 15, 2017
1 parent 6db8466 commit 71ee6b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/integrator_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ intervals(integrator::DEIntegrator) = IntegratorIntervals(integrator)
for x in vars
for j in 1:dims
if denseplot
push!(plot_vecs[j], u_n(plot_timeseries, x[j],integrator.sol,plott,plot_timeseries,0))
push!(plot_vecs[j], u_n(plot_timeseries, x[j],integrator.sol,plott,plot_timeseries))
else # just get values
if x[j] == 0
push!(plot_vecs[j], integrator.t)
Expand All @@ -113,7 +113,7 @@ intervals(integrator::DEIntegrator) = IntegratorIntervals(integrator)
for x in vars
for j in 1:dims
if denseplot
push!(plot_vecs[j], u_n(plot_timeseries, x[j],sol,plott,plot_timeseries,0))
push!(plot_vecs[j], u_n(plot_timeseries, x[j],sol,plott,plot_timeseries))
else # Just get values
if x[j] == 0
push!(plot_vecs[j], integrator.t)
Expand Down
24 changes: 8 additions & 16 deletions src/solutions/solution_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ end
end
else
# Plot for sparse output: use the timeseries itself
if end_idx == 0
if sol.tslocation == 0
plott = sol.t
plot_timeseries = sol.u
if plot_analytic
Expand All @@ -95,7 +95,7 @@ end
@assert length(var) == dims
end
# Should check that all have the same dims!
plot_vecs,labels = solplot_vecs_and_labels(dims,int_vars,plot_timeseries,plott,sol,plot_analytic,end_idx)
plot_vecs,labels = solplot_vecs_and_labels(dims,int_vars,plot_timeseries,plott,sol,plot_analytic)

tdir = sign(sol.t[end]-sol.t[1])
xflip --> tdir < 0
Expand Down Expand Up @@ -237,20 +237,12 @@ function add_analytic_labels!(labels,x,dims,sol)
end
end

function u_n(timeseries::AbstractArray, n::Int,sol,plott,plot_timeseries,end_idx)
function u_n(timeseries::AbstractArray, n::Int,sol,plott,plot_timeseries)
# Returns the nth variable from the timeseries, t if n == 0
if n == 0
if end_idx == 0
return plott
else
return plott[1:end_idx]
end
return plott
elseif n == 1 && !(typeof(sol[1]) <: AbstractArray)
if end_idx == 0
return timeseries
else
return timeseries[1:end_idx]
end
return timeseries
else
tmp = Vector{eltype(sol[1])}(length(plot_timeseries))
for j in 1:length(plot_timeseries)
Expand All @@ -260,23 +252,23 @@ function u_n(timeseries::AbstractArray, n::Int,sol,plott,plot_timeseries,end_idx
end
end

function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analytic,end_idx)
function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analytic)
plot_vecs = []
for i in 1:dims
push!(plot_vecs,[])
end
labels = String[]# Array{String, 2}(1, length(vars)*(1+plot_analytic))
for x in vars
for j in 1:dims
push!(plot_vecs[j], u_n(plot_timeseries, x[j],sol,plott,plot_timeseries,end_idx))
push!(plot_vecs[j], u_n(plot_timeseries, x[j],sol,plott,plot_timeseries))
end
add_labels!(labels,x,dims,sol)
end

if plot_analytic
for x in vars
for j in 1:dims
push!(plot_vecs[j], u_n(plot_timeseries, x[j],sol,plott,plot_timeseries,end_idx))
push!(plot_vecs[j], u_n(plot_timeseries, x[j],sol,plott,plot_timeseries))
end
add_analytic_labels!(labels,x,dims,sol)
end
Expand Down

0 comments on commit 71ee6b1

Please sign in to comment.