Skip to content

Commit

Permalink
fixup! feat: add discrete variables support to solution plot recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jul 4, 2024
1 parent 41a51d8 commit a20733b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/solutions/solution_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,18 @@ DEFAULT_PLOT_FUNC(x, y, z) = (x, y, z) # For v0.5.2 bug
ts = ts[tstart:tend]

vals = getp(sol, idx)(sol, tstart:tend)

# Scatterplot of points
@series begin
seriestype := :scatter
linestyle --> :dash
label --> string(hasname(idx) ? getname(idx) : idx)
ts, vals
end

@series begin
seriestype := :line
linestyle --> :dash
label := nothing
markershape --> :o
markersize --> repeat([2, 0], length(ts)-1)
markeralpha --> repeat([1, 0], length(ts)-1)
label --> string(hasname(idx) ? getname(idx) : idx)

xvals = collect(Iterators.flatten(zip(ts, ts)))[2:end]
yvals = collect(Iterators.flatten(zip(vals, vals)))[1:end-1]
xvals, yvals
x = vec([ts[1:end-1]'; ts[2:end]'])
y = repeat(vals, inner=2)[1:end-1]
x, y
end
end
end
Expand Down

0 comments on commit a20733b

Please sign in to comment.