ScottPlot.NET
GitHub Repo stars

Windows Forms Quickstart

Step 1: Install the ScottPlot.WinForms NuGet package

Step 2: Drag a FormsPlot from the Toolbox onto your Form

Step 3: Plot some data in your start-up sequence

This code sample is specific to ScottPlot 5 (details)
double[] dataX = { 1, 2, 3, 4, 5 };
double[] dataY = { 1, 4, 9, 16, 25 };

formsPlot1.Plot.Add.Scatter(dataX, dataY);
formsPlot1.Refresh();

Note for .NET Framework Users

ScottPlot 5 presently has an issue (#3300) specific to .NET Framework projects that causes the control to crash when added to a window by dragging it from the Visual Studio toolbox. Solutions include:

  • Create a .NET (not .NET Framework) project.
  • Add the control programmatically as described below.

How to add a Plot Control Programmatically

If users are not using the visual designer (or are having trouble locating the plot control in the toolbox), a FormsPlot can be added to the Form programmatically. See the FAQ: Add ScottPlot WinForms Control Programmatically page for additional information.

This code sample is specific to ScottPlot 5 (details)
using System.Windows.Forms;

namespace WinFormsQuickstart
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            var fp = new ScottPlot.WinForms.FormsPlot() { Dock = DockStyle.Fill };
            Controls.Add(fp);
        }
    }
}