# Common zscale for contour subplots

**URL:** <https://discourse.julialang.org/t/common-zscale-for-contour-subplots/86543>\
**Category:** General Usage\
**Tags:** plotting, plots, gr\
**Created:** [August 30, 2022, 12:09pm UTC](https://discourse.julialang.org/t/common-zscale-for-contour-subplots/86543 "2022-08-30T12:09:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [August 30, 2022, 12:09pm UTC](https://discourse.julialang.org/t/common-zscale-for-contour-subplots/86543/1 "2022-08-30T12:09:07Z")

</div>

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?

```julia
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))

```

 ![example](https://global.discourse-cdn.com/julialang/original/3X/7/4/74973706e713b8c30da781290fe19cdbf9180625.png)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 30, 2022, 2:00pm UTC](https://discourse.julialang.org/t/common-zscale-for-contour-subplots/86543/2 "2022-08-30T14:00:36Z")

</div>

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

```julia
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))

```

 ![Plots_contours_single_colorbar](https://global.discourse-cdn.com/julialang/original/3X/6/9/692f758069f7bdcb9eb1c148197b8da7c31a1af1.jpeg)

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [August 30, 2022, 4:24pm UTC](https://discourse.julialang.org/t/common-zscale-for-contour-subplots/86543/3 "2022-08-30T16:24:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 30, 2022, 4:28pm UTC](https://discourse.julialang.org/t/common-zscale-for-contour-subplots/86543/4 "2022-08-30T16:28:32Z")

</div>

It is under [Subplot Attributes](https://docs.juliaplots.org/latest/generated/attributes_subplot/).

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [August 30, 2022, 4:36pm UTC](https://discourse.julialang.org/t/common-zscale-for-contour-subplots/86543/5 "2022-08-30T16:36:11Z")

</div>

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