# How to use Makie's (CairoMakie) heatmap for a matrix with some empty positions?

**URL:** <https://discourse.julialang.org/t/how-to-use-makies-cairomakie-heatmap-for-a-matrix-with-some-empty-positions/101762>\
**Category:** Visualization\
**Tags:** makie, cairomakie\
**Created:** [July 19, 2023, 3:35am UTC](https://discourse.julialang.org/t/how-to-use-makies-cairomakie-heatmap-for-a-matrix-with-some-empty-positions/101762 "2023-07-19T03:35:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mantzaris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mantzaris/32/3852_2.png) [@mantzaris](https://discourse.julialang.org/u/mantzaris)\
**Post date:** [July 19, 2023, 3:35am UTC](https://discourse.julialang.org/t/how-to-use-makies-cairomakie-heatmap-for-a-matrix-with-some-empty-positions/101762/1 "2023-07-19T03:35:01Z")

</div>

I am using this code to produce a `heatmap` with `Makie` using the backend of `CairoMakie`

```julia
agent_money(xx,yy) = id_in_position( (xx,yy) , schelling ) > 0 ? schelling[id_in_position( (xx,yy) , schelling )].money : -1

xs = 1:13
ys = 1:13

fig, ax, hm = CairoMakie.heatmap(xs, ys, agent_money)
Colorbar(fig[:, end+1], hm)
fig

```

but some of the squares I just give a -1 value but are actually _empty_, how do I set them to be ignored or plotted with white or completely separately?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [July 19, 2023, 5:56am UTC](https://discourse.julialang.org/t/how-to-use-makies-cairomakie-heatmap-for-a-matrix-with-some-empty-positions/101762/2 "2023-07-19T05:56:52Z")

</div>

Use `NaN` for empty cells, by default those are transparent but you can change that via the `nan_color` attribute.
