ScottPlot.NET
Error Bars communicate the range of possible values for a measurement

This page is part of the ScottPlot 5.0 Cookbook

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");