Transparency in Plots

Hello,

I would like to plot a heatmap on top of a 2d map. Something like:

plot(geometry)
heatmap!(x, y, values)

The heatmap is consisting of a lot of zeros and I would like to be able to have all those zeros mapping to a transparent value (so they do not hide the map details).

Is there a colorscheme that can do that?

I already tried the opposite (first heatmap and then plot!) and setting the color (and background) of the map to transparent), which is relatively nice but the places where there is a large density of lines in the map hides completely the heatmap…

Thank you in advance for your help.

Best regards,
Orestis

Maybe replace your zeros with NaNs?

plot(geometry)
zerotonan(x) = x == 0 ? NaN : x
heatmap!(x, y, zerotonan.(values))
3 Likes

Thanks a lot! Works perfectly.