Alpha Map
An alpha map (a 2d array of byte values) can be used to apply custom transparency to each cell of a heatmap.
ScottPlot.Plot myPlot = new();
// data values are translated to color based on the heatmap's colormap
double[,] data = SampleData.MonaLisa();
// an alpha map controls transparency of each cell
byte[,] alphaMap = new byte[data.GetLength(0), data.GetLength(1)];
// fill the alpha map with values from 0 (transparent) to 255 (opaque)
for (int y = 0; y < alphaMap.GetLength(0); y++)
{
for (int x = 0; x < alphaMap.GetLength(1); x++)
{
double fractionAcross = (double)x / alphaMap.GetLength(1);
alphaMap[y, x] = (byte)(fractionAcross * 255);
}
}
// create a line chart
myPlot.Add.Signal(Generate.Sin());
myPlot.Add.Signal(Generate.Cos());
// plot the heatmap on top of the line chart
var hm = myPlot.Add.Heatmap(data);
hm.Position = new(10, 35, -1.5, .5);
hm.AlphaMap = alphaMap;
myPlot.SavePng("demo.png", 400, 300);
This recipe is one of many in the Heatmap category
