Single colorbar for heatmap grid layout

This does what you want but not directly.

julia> ps = [heatmap(rand(10,10), legend=:none) for i=1:2,j=1:2] # Make heatmaps without legends
2×2 Matrix{Plots.Plot{Plots.GRBackend}}:
 Plot{Plots.GRBackend() n=1}  Plot{Plots.GRBackend() n=1}
 Plot{Plots.GRBackend() n=1}  Plot{Plots.GRBackend() n=1}

julia> l = @layout[grid(2,2) a{0.05w}] # Stack a layout that rightmost one is for color bar
Plots.GridLayout(1, 2)

julia> p = plot(ps..., heatmap((0:0.01:1).*ones(101,1), legend=:none, xticks=:none, yticks=(1:10:101, string.(0:0.1:1))), layout=l) # Plot them set y values of color bar accordingly

julia> savefig(p, "plot.png")

plot

4 Likes