Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

透明なセル

ヒートマップのセルに double.NaN を代入すると、そのセルを透明にできます。

Heatmap.cs
ScottPlot.Plot myPlot = new();

// 2Dデータから始め、いくつかのセルをNaNに設定する
double[,] data = SampleData.MonaLisa();
for (int y = 20; y < 80; y++)
{
    for (int x = 20; x < 60; x++)
    {
        data[y, x] = double.NaN;
    }
}

// 折れ線グラフを作成する
myPlot.Add.Signal(Generate.Sin());
myPlot.Add.Signal(Generate.Cos());

// 折れ線グラフの上にヒートマップをプロットする
var hm1 = myPlot.Add.Heatmap(data);
hm1.Position = new(10, 35, -1.5, .5);

// NaNの透明色はカスタマイズできる
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);
このレシピは、ヒートマップカテゴリーに含まれる多数のレシピの1つです