This page is part of the ScottPlot 5.0 Cookbook
⚠️ ScottPlot 5.0.2-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.
Error Bar Quickstart
Error Bars go well with scatter plots.
ScottPlot.Plot myPlot = new();
int N = 50;
double[] xs = Generate.Consecutive(N);
double[] ys = Generate.RandomWalk(N);
double[] yErrPositive = Generate.Random(N, 0.1, 0.25);
double[] yErrNegative = Generate.Random(N, 0.1, 0.25);
var scatter = myPlot.Add.Scatter(xs, ys);
var errorBars = myPlot.Add.ErrorBar(xs, ys, yErrorPositive: yErrPositive, yErrorNegative: yErrNegative, color: scatter.LineStyle.Color);
myPlot.SavePng("error-bar-quickstart.png");
MultiDimensional ErrorBars
You can mix and match x and y error bars.
ScottPlot.Plot myPlot = new();
int N = 50;
double[] xs = Generate.Consecutive(N);
double[] ys = Generate.RandomWalk(N);
double[] xErrPositive = Generate.Random(N, 0.1, 0.25);
double[] xErrNegative = Generate.Random(N, 0.1, 0.25);
double[] yErrPositive = Generate.Random(N, 0.1, 0.25);
double[] yErrNegative = Generate.Random(N, 0.1, 0.25);
var scatter = myPlot.Add.Scatter(xs, ys);
var errorBars = myPlot.Add.ErrorBar(xs, ys, xErrPositive, xErrNegative, yErrPositive, yErrNegative, scatter.LineStyle.Color);
myPlot.SavePng("multidimensional-errorbars.png");