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.
Error Bar Quickstart
Error Bars go well with scatter plots.
ScottPlot.Plot myPlot = new();
int points = 30;
double[] xs = Generate.Consecutive(points);
double[] ys = Generate.RandomWalk(points);
double[] err = Generate.Random(points, 0.1, 1);
var scatter = myPlot.Add.Scatter(xs, ys);
var errorbars = myPlot.Add.ErrorBar(xs, ys, err);
errorbars.Color = scatter.Color;
myPlot.SavePng("error-bar-quickstart.png");
ErrorBar Values
Error size can be set for all dimensions.
ScottPlot.Plot myPlot = new();
int points = 10;
ScottPlot.RandomDataGenerator gen = new();
double[] xs = Generate.Consecutive(points);
double[] ys = Generate.RandomWalk(points);
var scatter = myPlot.Add.Scatter(xs, ys);
scatter.LineStyle.Width = 0;
ScottPlot.Plottables.ErrorBar eb = new(
xs: xs,
ys: ys,
xErrorsNegative: gen.RandomSample(points, .5),
xErrorsPositive: gen.RandomSample(points, .5),
yErrorsNegative: gen.RandomSample(points),
yErrorsPositive: gen.RandomSample(points));
eb.Color = scatter.Color;
myPlot.Add.Plottable(eb);
myPlot.SavePng("errorbar-values.png");