ScottPlot.NET
GitHub Repo stars

Quickstart

Scatter Plot

Display paired X/Y data as a scatter plot.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

double[] dataX = { 1, 2, 3, 4, 5 };
double[] dataY = { 1, 4, 9, 16, 25 };
myPlot.Add.Scatter(dataX, dataY);

myPlot.SavePng("demo.png", 400, 300);

Customizing Plottables

Functions that add things to plots return the plottables they create. Interact with the properties of plottables to customize their styling and behavior.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

double[] dataX = { 1, 2, 3, 4, 5 };
double[] dataY = { 1, 4, 9, 16, 25 };
var myScatter = myPlot.Add.Scatter(dataX, dataY);
myScatter.Color = Colors.Green.WithOpacity(.2);
myScatter.LineWidth = 5;
myScatter.MarkerSize = 15;

myPlot.SavePng("demo.png", 400, 300);

Signal Plot

Signal plots are optimized for displaying evenly spaced data.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

double[] sin = Generate.Sin(51);
double[] cos = Generate.Cos(51);
myPlot.Add.Signal(sin);
myPlot.Add.Signal(cos);

myPlot.SavePng("demo.png", 400, 300);

Signal Plot Performance

Signal plots can interactively display millions of data points in real time. Double-click the plot to display performance benchmarks.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

double[] data = Generate.RandomWalk(1_000_000);
myPlot.Add.Signal(data);
myPlot.Title("Signal plot with one million points");

myPlot.SavePng("demo.png", 400, 300);

Axis Labels

Axis labels can be extensively customized.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

myPlot.Add.Signal(Generate.Sin(51));
myPlot.Add.Signal(Generate.Cos(51));

myPlot.XLabel("Horizonal Axis");
myPlot.YLabel("Vertical Axis");
myPlot.Title("Plot Title");

myPlot.SavePng("demo.png", 400, 300);

Legend

A legend displays plottables in a key along the edge of a plot. Most plottables have a Label property which configures what text appears in the legend.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

var sig1 = myPlot.Add.Signal(Generate.Sin(51));
sig1.Label = "Sin";

var sig2 = myPlot.Add.Signal(Generate.Cos(51));
sig2.Label = "Cos";

myPlot.ShowLegend();

myPlot.SavePng("demo.png", 400, 300);

Add Plottables Manually

Although the Plot.Add class has many helpful methods for creating plottable objects and adding them to the plot, users can instantiate plottable objects themselves and use Add.Plottable() to place it on the plot. This stategy allows users to create their own plottables (implementing IPlottable) with custom appearance or behavior.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

// create a plottable and modify it as desired
ScottPlot.Plottables.Marker marker = new()
{
    X = 2,
    Y = 3,
    Size = 20,
    Color = Colors.Magenta,
    Shape = MarkerShape.OpenDiamond,
    Label = "My Marker",
};

// add the custom plottable to the plot
myPlot.Add.Plottable(marker);

myPlot.ShowLegend();

myPlot.SavePng("demo.png", 400, 300);