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

ヒートマップのセルラベル

セル上にテキストを配置して、セルラベルを提供できます。インタラクティブなアプリケーションでは、MouseMove イベントを使用して古いラベルを削除し、マウスの下にあるセル上にのみラベルを表示できます。詳細とコードサンプルについては、ScottPlot Demo ページを参照してください。

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

double[,] data = {
    { 1, 2, 3 },
    { 4, 5, 6 },
    { 7, 8, 9 },
};

var hm = myPlot.Add.Heatmap(data);

for (int y = 0; y < data.GetLength(0); y++)
{
    for (int x = 0; x < data.GetLength(1); x++)
    {
        Coordinates coordinates = new(x, y);
        string cellLabel = data[y, x].ToString("0.0");
        var text = myPlot.Add.Text(cellLabel, coordinates);
        text.Alignment = Alignment.MiddleCenter;
        text.LabelFontSize = 30;
        text.LabelFontColor = Colors.White;
    }
}

myPlot.SavePng("demo.png", 400, 300);
このレシピは、ヒートマップカテゴリに含まれる多数のレシピの 1 つです