Open behinger opened 1 year ago
maybe use the spy!
function (currently needs explicit marker=:circle
)
Using spy in a figure like this
X_oc = modelmatrix(m_overlapCorr);
let
sfreq = 100
nsamples = 500
evts_τ = 0.4*sfreq
n_τ = size(data_epochs, 2)
f = Figure();
ax = Axis(f[1,1], title = "Sparcity Pattern of the Model Matrix",
xlabel="Trials (global time t)", ylabel="Conditions (local time τ)")
# sparsity pattern
sp = spy!(ax, X_oc[1:nsamples,:],
marker = :cross, markersize=4,
colormap = :PuOr, #colormap = cgrad(:Spectral, 9, categorical = true))
colorrange = (-4, 4),
framecolor = :transparent,
nan_color = :green
)
# indicate events
vl_evts = vlines!(evts[evts.latency .<= nsamples, :latency],
color=:green, alpha=0.2,
linestyle=:dash,
)
hl_evts = hlines!([evts_τ, evts_τ+n_τ, evts_τ+n_τ*2],
color=:green, alpha=0.2,
linestyle=:dash,
)
# separate linear comp. in formula
hl = hlines!([n_τ, n_τ*2]; color=:grey, alpha=0.6)
#hidespines!(ax)
hidedecorations!(ax, ticks=false, label=false, ticklabels=false)
Colorbar(f[2,1], sp, vertical=false)
Legend(f[1,2],
[sp, [vl_evts, hl_evts]],
["entries in the sparse matrix", "events"]
)
f
end
results in the plot
It would be nice to rotate the plot 90 degree clockwise to actually match the matrix pattern