NeuroAnalyzer tutorials: Tiled plots

As an example, a tiled plot of labeled auto-covariance plots will be created.

First, we need data to plot:

ac, lags = acov(eeg, lag=5)
l = labels(eeg)[signal_channels(eeg)]

Next, a vector of plots has to be created:

p = Plots.Plot{Plots.GRBackend}[]
for idx in 1:size(ac, 1)
    push!(p, plot_xac(ac[idx, :], lags, title=l[idx]))

There is also plot_compose() function available:

plot_compose(p[1:7], layout=(4, 2))

This can also be done manually. Create a tiled plot (two columns) of first seven plots. First example is to plot even number of plots in two columns:

p = p[1:7]
# add empty plot in case of odd number of sub-plots
isodd(length(p)) && push!(p, Plots.plot(border=:none, title=""))
p = Plots.plot(p..., layout=(length(p) ÷ 2, 2))
plot_save(p, file_name="images/multi-acov.png")

It is also possible to combine different plots using complex layout:

p1 = plot(eeg, ch=1:2)
p2 = plot_psd(eeg, ch=1, ep=1)
p3 = plot_electrodes(eeg, ch=signal_channels(eeg), selected=1:2, plot_size=200, labels=false)

# @layout macro requires Plots package to be loaded
l = @layout [a b; c{0.2h}]
p = Plots.plot!(p1, p2, p3, layout=l)
plot_save(p, file_name="images/complex_layout.png")