Julia Makie merge/overlay plots

Howdy again. Maybe it would make sense to just do the computation ahead of time, and then display the resulting heatmaps?

using CairoMakie

# Data
Z_green, Z_red = rand(3, 4), rand(3, 4)
Z_diff = @. 1.0 - abs(Z_red - Z_green)

# Plot
fig = Figure()

Zs = Z_green, Z_red, Z_diff
colormaps = :reds, :greens, :heat

for (i, (Z, colormap)) ∈ enumerate(zip(Zs, colormaps))
    ax = Axis(fig[1, 2*i - 1]; width=250, height=250)
    hm = heatmap!(ax, permutedims(Z); colorrange=(0, 1), colormap)
    Colorbar(fig[1, 2*i], hm)
end

resize_to_layout!(fig)

fig

4 Likes