多图快速入门
使用 Multiplot 类创建具有多个子图的图形。
ScottPlot.Multiplot multiplot = new();
// configure the multiplot to use 2 subplots
multiplot.AddPlots(2);
Plot plot1 = multiplot.Subplots.GetPlot(0);
Plot plot2 = multiplot.Subplots.GetPlot(1);
// add sample data to each subplot
plot1.Add.Signal(Generate.Sin());
plot2.Add.Signal(Generate.Cos());
WpfPlot1.Refresh();
多图列
Multiplot 的 Layout 属性可以自定义以实现列布局。
ScottPlot.Multiplot multiplot = new();
// configure the multiplot to use 2 subplots
multiplot.AddPlots(2);
Plot plot1 = multiplot.Subplots.GetPlot(0);
Plot plot2 = multiplot.Subplots.GetPlot(1);
// add sample data to each subplot
plot1.Add.Signal(Generate.Sin());
plot2.Add.Signal(Generate.Cos());
// apply a custom layout
multiplot.Layout = new ScottPlot.MultiplotLayouts.Columns();
WpfPlot1.Refresh();
多图网格
Multiplot 的 Layout 属性可以自定义以实现网格布局。
ConsoleWinFormsWPFOther
ScottPlot.Multiplot multiplot = new();
// configure the multiplot to have 6 subplots
multiplot.AddPlots(6);
// add sample data to each subplot
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);
}
// configure the multiplot to use a grid layout
multiplot.Layout = new ScottPlot.MultiplotLayouts.Grid(rows: 2, columns: 3);
WpfPlot1.Refresh();
多图自定义布局
Multiplot 的 Layout 属性可以配置为实现完全自定义的布局。
ScottPlot.Multiplot multiplot = new();
// configure the multiplot to have 3 subplots
multiplot.AddPlots(3);
// add sample data to each subplot
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);
}
// create a custom grid layout and define the position of each subplot
ScottPlot.MultiplotLayouts.CustomGrid gridLayout = new();
gridLayout.Set(multiplot.GetPlot(0), new GridCell(0, 0, 2, 1)); // double wide
gridLayout.Set(multiplot.GetPlot(1), new GridCell(1, 0, 2, 2)); // bottom left
gridLayout.Set(multiplot.GetPlot(2), new GridCell(1, 1, 2, 2)); // bottom right
// user the custom layout in our multiplot
multiplot.Layout = gridLayout;
WpfPlot1.Refresh();