Interpolation of heatmap with semi-transparent colormaps in Makie

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:

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

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

Thanks for any help!

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

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:

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.

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. :grin:

For anyone interested I created a github issue here:

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