# Different colors regions for different heatmaps

**URL:** <https://discourse.julialang.org/t/different-colors-regions-for-different-heatmaps/24207>\
**Category:** Visualization\
**Created:** [May 14, 2019, 12:22pm UTC](https://discourse.julialang.org/t/different-colors-regions-for-different-heatmaps/24207 "2019-05-14T12:22:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noel\_Araujo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noel_araujo/32/4862_2.png) [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Post date:** [May 14, 2019, 12:22pm UTC](https://discourse.julialang.org/t/different-colors-regions-for-different-heatmaps/24207/1 "2019-05-14T12:22:58Z")

</div>

Hello internet

Basically I’m doing are simple heatmaps with different color limits as in these examples:

```julia
using Plots
pyplot()
h1 = heatmap(1:10, 1:15, rand(15,10), clim=(0,0.5))
h2 = heatmap(1:10, 1:15, rand(15,10), clim=(0.5,1))
plot(h1,h2, size=(800,400))

```

 ![sample_heatmap1](https://global.discourse-cdn.com/julialang/original/3X/c/5/c5710e8e3af20c2526100c48b0e2ae0e93b464e8.png)

But look at the color scheme. It _begins_ from dark to bright again at each new figure.

I would like that in “half of the dark spectra of colors” to be used in figure at left, and “half of the bright” color at the figure of the right. This example has only 2 divisions, and I’m looking for a general case.

I don’t know the proper words to ask for google/discourse search, but if someone has the answer for this problem in other package I’m open mind.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [May 14, 2019, 12:44pm UTC](https://discourse.julialang.org/t/different-colors-regions-for-different-heatmaps/24207/2 "2019-05-14T12:44:21Z")

</div>

The best approach is to set the color limits for the color bar. `clim = (0,1)`

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [May 14, 2019, 12:52pm UTC](https://discourse.julialang.org/t/different-colors-regions-for-different-heatmaps/24207/3 "2019-05-14T12:52:51Z")

</div>

Ah, I see what you mean. That’s not how it’s intended to be used. But you can create your own gradient by chopping the inbuilt one in halves:

```julia
magma = cgrad(:magma).colors
c1 = cgrad(magma[1:15])
c2 = cgrad(magma[16:end])
h1 = heatmap(1:10, 1:15, rand(15,10), clim=(0,0.5), c = c1)
h2 = heatmap(1:10, 1:15, rand(15,10), clim=(0.5,1), c = c2)
plot(h1,h2, size=(800,400))

```

 ![36](https://global.discourse-cdn.com/julialang/original/3X/d/0/d034afc0ac1540c57807b7fa39ef525238fdbc51.png)

---

<div class="post-metadata">

**Author:** ![Noel\_Araujo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/noel_araujo/32/4862_2.png) [@Noel\_Araujo](https://discourse.julialang.org/u/Noel_Araujo)\
**Post date:** [May 14, 2019, 12:57pm UTC](https://discourse.julialang.org/t/different-colors-regions-for-different-heatmaps/24207/5 "2019-05-14T12:57:25Z")

</div>

Now that I see your solution, I had a good guess of how to solve my problem, but I was missing the `.colors` in `cgrad()`
