Transparency in Plots


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

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,

Maybe replace your zeros with NaNs?

zerotonan(x) = x == 0 ? NaN : x
heatmap!(x, y, zerotonan.(values))

Thanks a lot! Works perfectly.