# Interpolation of heatmap with semi-transparent colormaps in Makie

**URL:** <https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947>\
**Category:** General Usage\
**Tags:** question, plotting, colors, makie\
**Created:** [January 26, 2021, 1:15am UTC](https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947 "2021-01-26T01:15:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfmiller940](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sfmiller940/32/21378_2.png) [@sfmiller940](https://discourse.julialang.org/u/sfmiller940)\
**Post date:** [January 26, 2021, 1:15am UTC](https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947/1 "2021-01-26T01:15:46Z")

</div>

Hello,

I’ve been try make heatmaps using colormaps that go from transparent to either white or black.

The interpolation works as expected for black but it looks terrible for white.

Here’s some sample code with the result:

```julia
using CairoMakie, Plots

xs = LinRange(0, 10, 100)
ys = LinRange(0,10, 100)
zs = [x+im*y for x in xs, y in ys]
rings = abs.(zs) .% 3

fig = Figure();
ax1 = fig[1, 1] = Axis( fig, backgroundcolor="blue");
ax2 = fig[2, 1] = Axis( fig, backgroundcolor="blue");

cmblack = cgrad(range(HSLA(0,0,0,0), stop=HSLA(0,0,0,1), length=100));
CairoMakie.heatmap!(ax1, xs, ys, rings, colormap=cmblack, interpolate=true);

cmwhite = cgrad(range(HSLA(0,0,1,0), stop=HSLA(0,0,1,1), length=100));
CairoMakie.heatmap!(ax2, xs, ys, rings, colormap=cmwhite, interpolate=true);

fig

```

 ![interpolation](https://global.discourse-cdn.com/julialang/original/3X/8/3/83f9069d7a4a6615bb401691500db6aca58ee229.png)

What’s going on here? Is there any way to make the white colormap look like the black one?

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Post date:** [January 26, 2021, 4:44am UTC](https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947/2 "2021-01-26T04:44:54Z")

</div>

FWIW, I can’t get your output myself. Maybe it’s a PNG issue?

---

<div class="post-metadata">

**Author:** ![sfmiller940](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sfmiller940/32/21378_2.png) [@sfmiller940](https://discourse.julialang.org/u/sfmiller940)\
**Post date:** [January 26, 2021, 5:47am UTC](https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947/3 "2021-01-26T05:47:37Z")

</div>

Thanks that’s still helpful. Are you using CairoMakie too or another backend?

The picture above is actually a screenshot from Atom/Juno.

I just tried saving to PNG, but still wacky. Black is fine. White seems completely white:

 ![interpol](https://global.discourse-cdn.com/julialang/original/3X/5/e/5e4bc21fd2f73f34113d189e5536c9443f43e06a.png)

---

<div class="post-metadata">

**Author:** ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)\
**Post date:** [January 26, 2021, 5:52am UTC](https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947/4 "2021-01-26T05:52:12Z")

</div>

Yes I tried CairoMakie and GLMakie, and got what you have with CairoMakie. My guess is that no one has tried a `cgrad` with changing `alpha`? Maybe worth an issue?

PS: side note, you don’t need `using Plots`, I think `using Colors` is sufficient in your case.

---

<div class="post-metadata">

**Author:** ![sfmiller940](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sfmiller940/32/21378_2.png) [@sfmiller940](https://discourse.julialang.org/u/sfmiller940)\
**Post date:** [January 26, 2021, 5:57pm UTC](https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947/5 "2021-01-26T17:57:44Z")

</div>

Yeah, I’ll post something to CairoMakie github about this.

Thanks for checking GLMakie (and for the tip about Plots/Colors).

I get errors when I build GLMakie, but now I’ve got more motivation to debug that. Separate issue. 😁

---

<div class="post-metadata">

**Author:** ![sfmiller940](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sfmiller940/32/21378_2.png) [@sfmiller940](https://discourse.julialang.org/u/sfmiller940)\
**Post date:** [January 26, 2021, 9:58pm UTC](https://discourse.julialang.org/t/interpolation-of-heatmap-with-semi-transparent-colormaps-in-makie/53947/6 "2021-01-26T21:58:35Z")

</div>

For anyone interested I created a github issue here:

[https://github.com/JuliaPlots/CairoMakie.jl/issues/132](https://github.com/JuliaPlots/CairoMakie.jl/issues/132)

And I still can’t get GLMakie to build, but I got this working with WGLMakie.
