This page is part of the ScottPlot 5.0 Cookbook
⚠️ ScottPlot 5.0.8-beta is a preview package
This page describes a beta release of ScottPlot. It is available on NuGet as a preview package, but its API is not stable and it is not recommended for production use. See the ScottPlot Versions page for more information.
Scatter Plot
Display paired X/Y data as a scatter plot.
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("scatter-plot.png");
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.
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.LineStyle.Width = 5;
myScatter.LineStyle.Color = Colors.Green.WithOpacity(.2);
myScatter.MarkerStyle.Fill.Color = Colors.Magenta;
myScatter.MarkerStyle.Size = 15;
myPlot.SavePng("customizing-plottables.png");
Signal Plot
Signal plots are optimized for displaying evenly spaced data.
ScottPlot.Plot myPlot = new();
double[] sin = Generate.Sin(51);
double[] cos = Generate.Cos(51);
myPlot.Add.Signal(sin);
myPlot.Add.Signal(cos);
myPlot.SavePng("signal-plot.png");
Signal Plot Performance
Signal plots can interactively display millions of data points in real time. Double-click the plot to display performance benchmarks.
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("signal-plot-performance.png");
Axis Labels
Axis labels can be extensively customized.
ScottPlot.Plot myPlot = new();
myPlot.Add.Signal(Generate.Sin(51));
myPlot.Add.Signal(Generate.Cos(51));
myPlot.XAxis.Label.Text = "Horizonal Axis";
myPlot.YAxis.Label.Text = "Vertical Axis";
myPlot.TitlePanel.Label.Text = "Plot Title";
myPlot.SavePng("axis-labels.png");
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.
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.Legend();
myPlot.SavePng("legend.png");