Plots.Heatmap: how to set colour of NaN values?

dankelley
Sat, 04 Oct 2025 14:05:03 +0000
Visualization

I tried the following, which I thought would have a red box in the middle. But the box is white. Is there a way for me to control this? (Note: I’m a newbie, and sticking to base Plots for now. I’m hoping to not have my Julia scripts using a range of plotting subsystems.)

using Plots
data = rand(10, 10);
data[3:7, 3:7] .= NaN;
heatmap(data, background_color_plot=:red)

I’m using Julia 1.11.7 on a macos machine updated to the latest beta version of the Tahoe 26.1 OS.

3 posts - 2 participants