C# 中使用 Scottpot 工具进行绘图

C# 中使用 Scottpot 工具进行绘图

编码文章call10242025-07-27 14:16:063A+A-

Scottpot 工具介绍

ScottPlot 是一个免费的开源 .NET 绘图库,可以轻松交互式显示大型数据集,只需几行代码即可创建折线图、条形图、饼图、散点图等。

常用的绘图方式及样例介绍

1)散点图(Scatter Plot)

散点图具有成对的X/Y值数据点,也就是俗称的XY图

散点图绘图示例:

            var plt = new ScottPlot.Plot(1200, 800);

            // sample data
            double[] xs = DataGen.Consecutive(51);
            double[] sin = DataGen.Sin(51);
            double[] cos = DataGen.Cos(51);

            // plot the data
            plt.AddScatter(xs, sin);
            plt.AddScatter(xs, cos);

            // customize the axis labels
            plt.Title("ScottPlot XY Plot Demo");
            plt.XLabel("Horizontal Axis");
            plt.YLabel("Vertical Axis");

            plt.SaveFig("scatter.png");

程序运行效果:

2)信号图(Signal Plot)

信号图具有均匀分布的 Y 点,信号图作图速度非常快,可以交互式显示数百万个数据点。有许多不同类型的可绘制对象,每个对象都有不同的用途。

信号绘图示例:

            var plt = new ScottPlot.Plot(1200, 800);

            double[] values = DataGen.RandomWalk(1_000_000);
            plt.AddSignal(values, sampleRate: 48_000);
            plt.Title("One Million Points");

            plt.SaveFig("signal plot.png");

程序运行效果:

点击这里复制本文地址 以上内容由文彬编程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

文彬编程网 © All Rights Reserved.  蜀ICP备2024111239号-4