Transparent Cells
Assign double.NaN to a heatmap cell to make it transparent.
ScottPlot.Plot myPlot = new();
// start with 2D data and set some cells to NaN
double[,] data = SampleData.MonaLisa();
for (int y = 20; y < 80; y++)
{
for (int x = 20; x < 60; x++)
{
data[y, x] = double.NaN;
}
}
// create a line chart
myPlot.Add.Signal(Generate.Sin());
myPlot.Add.Signal(Generate.Cos());
// plot the heatmap on top of the line chart
var hm1 = myPlot.Add.Heatmap(data);
hm1.Position = new(10, 35, -1.5, .5);
// the NaN transparency color can be customized
var hm2 = myPlot.Add.Heatmap(data);
hm2.Position = new(40, 55, -.5, .75);
hm2.NaNCellColor = Colors.Magenta.WithAlpha(.4);
myPlot.SavePng("demo.png", 400, 300);
This recipe is one of many in the Heatmap category
