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