Common zscale for contour subplots

Hi all,

I have a group of contour subplots (see below). I would like to reduce the scales to one, rather than have redundant scales. I am trying to figure out how to (1) remove white space in color scale for missing values, and (2) suppress the color scales on the subplots in the top row. How can this be achieved?

using Plots 

config = (
    xaxis = font(8),
    yaxis = font(8),
    titlefontsize = 10,
    clims = (10,250)
)

x = 1:0.5:20
y = 1:0.5:10
f(x, y, β) = begin
        (β * x + y ^ 2) * abs(sin(x) + cos(y))
    end
X = repeat(reshape(x, 1, :), length(y), 1)
Y = repeat(y, 1, length(x))
Z = map((x,y) -> f(x, y, 2.5), X, Y)
p1 = contour(x, y, Z, 
    fill = true, xlabel="x", ylabel="y",
    title = "a"; config...)

Z = map((x,y) -> f(x, y, .8), X, Y)
p2 = contour(x, y, Z, 
    fill = true, xlabel="x", ylabel="y",
    title = "b"; config...)

Z = map((x,y) -> f(x, y, .1), X, Y)
p3 = contour(x, y, Z, 
    fill = true, xlabel="x", ylabel="y",
    title = "c"; config...)

layout = @layout [a b; c]
plot(p1, p2, p3; layout, dpi=300, size=(340,300))

One way is to define colorbar=false in all 3 subplots and then use @layout to add the single colorbar:

p4 = plot(p3, framestyle=:none, colorbar=true, title="", lims=(-2,-2); config...); # empty plot
layout = @layout [[a b; c] d{0.05w}]
plot(p1, p2, p3, p4; layout, dpi=600, size=(680,600))

1 Like

Thanks! This is exactly what I need. Unfortunately, I had trouble finding the colorbar keyword in the docs.

It is under Subplot Attributes.

1 Like

Unfortunately, my problem was even more fundamental. I did not know the name for the color bar. I was looking under z scale :laughing:

1 Like