Skip to content

Commit

Permalink
add option for static or dynamic gap in stackplot (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
harisorgn authored Oct 4, 2024
1 parent 466552e commit f3dbbf3
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions ext/MakieExtension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ end

@recipe(StackPlot, blox, sol) do scene
Theme(
color = :black,
dynamic_gap = false,
Axis = (
xlabel = "Time (ms)",
ylabel = "Neurons",
Expand All @@ -146,15 +146,22 @@ function Makie.plot!(p::StackPlot)
mx = maximum(V; dims = 1)
mn = minimum(V; dims = 1)

offset = 0.0
for (i, V_neuron) in enumerate(eachcol(V))
if i == 1
lines!(p, sol.t, V_neuron; color=p.color[])
else
offset += abs(mn[i]) * 1.2
lines!(p, sol.t, offset .+ V_neuron; color=p.color[])
if p.dynamic_gap[]
offset = 0.0
for (i, V_neuron) in enumerate(eachcol(V))
if i == 1
lines!(p, sol.t, V_neuron)
else
offset += abs(mn[i]) * 1.2
lines!(p, sol.t, offset .+ V_neuron)
end
offset += abs(mx[i]) * 1.2
end
else
offset = maximum(mx .- mn)
for (i, V_neuron) in enumerate(eachcol(V))
lines!(p, sol.t, (i - 1) * offset .+ V_neuron)
end
offset += abs(mx[i]) * 1.2
end

return p
Expand Down

0 comments on commit f3dbbf3

Please sign in to comment.