# Transparency in Plots

**URL:** <https://discourse.julialang.org/t/transparency-in-plots/54409>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [February 1, 2021, 7:00pm UTC](https://discourse.julialang.org/t/transparency-in-plots/54409 "2021-02-01T19:00:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![orestis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orestis/32/21602_2.png) [@orestis](https://discourse.julialang.org/u/orestis)\
**Post date:** [February 1, 2021, 7:00pm UTC](https://discourse.julialang.org/t/transparency-in-plots/54409/1 "2021-02-01T19:00:38Z")

</div>

Hello,

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

```julia
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

---

<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:** [February 2, 2021, 1:06am UTC](https://discourse.julialang.org/t/transparency-in-plots/54409/2 "2021-02-02T01:06:15Z")

</div>

Maybe replace your zeros with `NaN`s?

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

```

---

<div class="post-metadata">

**Author:** ![orestis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orestis/32/21602_2.png) [@orestis](https://discourse.julialang.org/u/orestis)\
**Post date:** [February 3, 2021, 4:41pm UTC](https://discourse.julialang.org/t/transparency-in-plots/54409/3 "2021-02-03T16:41:58Z")

</div>

> [@briochemc](#):
>
> ```julia
> zerotonan(x) = x == 0 ? NaN : x
> heatmap!(x, y, zerotonan.(values))
> 
> ```

Thanks a lot! Works perfectly.
