@@ -69,11 +69,12 @@ DEFAULT_PLOT_FUNC(x,y,z) = (x,y,z) # For v0.5.2 bug
69
69
tspan = nothing , axis_safety = 0.1 ,
70
70
vars= nothing )
71
71
72
- int_vars = interpret_vars (vars,sol)
72
+ syms = getsyms (sol)
73
+ int_vars = interpret_vars (vars,sol,syms)
73
74
tscale = get (plotattributes, :xscale , :identity )
74
75
plot_vecs,labels = diffeq_to_arrays (sol,plot_analytic,denseplot,
75
76
plotdensity,tspan,axis_safety,
76
- vars,int_vars,tscale)
77
+ vars,int_vars,tscale,syms )
77
78
78
79
tdir = sign (sol. t[end ]- sol. t[1 ])
79
80
xflip --> tdir < 0
@@ -146,7 +147,17 @@ DEFAULT_PLOT_FUNC(x,y,z) = (x,y,z) # For v0.5.2 bug
146
147
(plot_vecs... ,)
147
148
end
148
149
149
- function diffeq_to_arrays (sol,plot_analytic,denseplot,plotdensity,tspan,axis_safety,vars,int_vars,tscale)
150
+ function getsyms (sol)
151
+ if has_syms (sol. prob. f)
152
+ return sol. prob. f. syms
153
+ elseif typeof (sol. u[1 ]) <: Union{LabelledArrays.LArray,LabelledArrays.SLArray}
154
+ return LabelledArrays. symnames (typeof (sol. u[1 ]))
155
+ else
156
+ return nothing
157
+ end
158
+ end
159
+
160
+ function diffeq_to_arrays (sol,plot_analytic,denseplot,plotdensity,tspan,axis_safety,vars,int_vars,tscale,syms)
150
161
if tspan === nothing
151
162
if sol. tslocation == 0
152
163
end_idx = length (sol)
@@ -217,21 +228,21 @@ function diffeq_to_arrays(sol,plot_analytic,denseplot,plotdensity,tspan,axis_saf
217
228
@assert length (var) == dims
218
229
end
219
230
# Should check that all have the same dims!
220
- plot_vecs,labels = solplot_vecs_and_labels (dims,int_vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries)
231
+ plot_vecs,labels = solplot_vecs_and_labels (dims,int_vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries,syms )
221
232
end
222
233
223
- function interpret_vars (vars,sol)
224
- if vars != = nothing && has_syms (sol . prob . f)
234
+ function interpret_vars (vars,sol,syms )
235
+ if vars != = nothing && syms != = nothing
225
236
# Do syms conversion
226
237
tmp_vars = []
227
238
for var in vars
228
239
if typeof (var) <: Symbol
229
- var_int = something (findfirst (isequal (var), sol . prob . f . syms), 0 )
240
+ var_int = something (findfirst (isequal (var), syms), 0 )
230
241
elseif typeof (var) <: Union{Tuple,AbstractArray} # eltype(var) <: Symbol # Some kind of iterable
231
242
tmp = []
232
243
for x in var
233
244
if typeof (x) <: Symbol
234
- push! (tmp,something (findfirst (isequal (x), sol . prob . f . syms), 0 ))
245
+ push! (tmp,something (findfirst (isequal (x), syms), 0 ))
235
246
else
236
247
push! (tmp,x)
237
248
end
@@ -314,14 +325,14 @@ function interpret_vars(vars,sol)
314
325
vars
315
326
end
316
327
317
- function add_labels! (labels,x,dims,sol)
328
+ function add_labels! (labels,x,dims,sol,syms )
318
329
lys = []
319
330
for j in 3 : dims
320
331
if x[j] == 0
321
332
push! (lys," t," )
322
333
else
323
- if has_syms (sol . prob . f)
324
- push! (lys," $(sol . prob . f . syms[x[j]]) ," )
334
+ if syms != = nothing
335
+ push! (lys," $(syms[x[j]]) ," )
325
336
else
326
337
push! (lys," u$(x[j]) ," )
327
338
end
@@ -331,8 +342,8 @@ function add_labels!(labels,x,dims,sol)
331
342
if x[2 ] == 0 && dims == 3
332
343
tmp_lab = " $(lys... ) (t)"
333
344
else
334
- if has_syms (sol . prob . f) && x[2 ] != 0
335
- tmp = sol . prob . f . syms[x[2 ]]
345
+ if syms != = nothing && x[2 ] != 0
346
+ tmp = syms[x[2 ]]
336
347
tmp_lab = " ($tmp ,$(lys... ) )"
337
348
else
338
349
if x[2 ] == 0
@@ -350,14 +361,14 @@ function add_labels!(labels,x,dims,sol)
350
361
labels
351
362
end
352
363
353
- function add_analytic_labels! (labels,x,dims,sol)
364
+ function add_analytic_labels! (labels,x,dims,sol,syms )
354
365
lys = []
355
366
for j in 3 : dims
356
367
if x[j] == 0 && dims == 3
357
368
push! (lys," t," )
358
369
else
359
- if has_syms (sol . prob . f)
360
- push! (lys,string (" True " ,sol . prob . f . syms[x[j]]," ," ))
370
+ if syms != = nothing
371
+ push! (lys,string (" True " ,syms[x[j]]," ," ))
361
372
else
362
373
push! (lys," True u$(x[j]) ," )
363
374
end
@@ -367,8 +378,8 @@ function add_analytic_labels!(labels,x,dims,sol)
367
378
if x[2 ] == 0
368
379
tmp_lab = " $(lys... ) (t)"
369
380
else
370
- if has_syms (sol . prob . f)
371
- tmp = string (" True " ,sol . prob . f . syms[x[2 ]])
381
+ if syms != = nothing
382
+ tmp = string (" True " ,syms[x[2 ]])
372
383
tmp_lab = " ($tmp ,$(lys... ) )"
373
384
else
374
385
tmp_lab = " (True u$(x[2 ]) ,$(lys... ) )"
@@ -396,7 +407,7 @@ function u_n(timeseries::AbstractArray, n::Int,sol,plott,plot_timeseries)
396
407
end
397
408
end
398
409
399
- function solplot_vecs_and_labels (dims,vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries)
410
+ function solplot_vecs_and_labels (dims,vars,plot_timeseries,plott,sol,plot_analytic,plot_analytic_timeseries,syms )
400
411
plot_vecs = []
401
412
labels = String[]
402
413
for x in vars
@@ -416,7 +427,7 @@ function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analyt
416
427
end
417
428
push! (plot_vecs[i],tmp[i])
418
429
end
419
- add_labels! (labels,x,dims,sol)
430
+ add_labels! (labels,x,dims,sol,syms )
420
431
end
421
432
422
433
@@ -434,7 +445,7 @@ function solplot_vecs_and_labels(dims,vars,plot_timeseries,plott,sol,plot_analyt
434
445
for i in eachindex (tmp)
435
446
push! (plot_vecs[i],tmp[i])
436
447
end
437
- add_analytic_labels! (labels,x,dims,sol)
448
+ add_analytic_labels! (labels,x,dims,sol,syms )
438
449
end
439
450
end
440
451
plot_vecs = [hcat (x... ) for x in plot_vecs]
0 commit comments