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

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

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)

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?

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

1 Like