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

Multiplot のカスタムレイアウト

Multiplot の Layout プロパティは、完全にカスタムなレイアウトを実現するように設定できます。

ScottPlot.Multiplot multiplot = new();

// multiplot が 3 つのサブプロットを持つように設定する
multiplot.AddPlots(3);

// 各サブプロットにサンプルデータを追加する
for (int i = 0; i < multiplot.Subplots.Count; i++)
{
    Plot plot = multiplot.GetPlot(i);
    double[] ys = Generate.Sin(oscillations: i + 1);
    plot.Add.Signal(ys);
}

// カスタムグリッドレイアウトを作成し、各サブプロットの位置を定義する
ScottPlot.MultiplotLayouts.CustomGrid gridLayout = new();
gridLayout.Set(multiplot.GetPlot(0), new GridCell(0, 0, 2, 1)); // 横幅 2 倍
gridLayout.Set(multiplot.GetPlot(1), new GridCell(1, 0, 2, 2)); // 左下
gridLayout.Set(multiplot.GetPlot(2), new GridCell(1, 1, 2, 2)); // 右下

// multiplot でカスタムレイアウトを使用する
multiplot.Layout = gridLayout;

multiplot.SavePng("demo.png", 400, 400);
このレシピは、Multiplot カテゴリにある多数のレシピの 1 つです