ScottPlot.NET
GitHub Repo stars

Annotation

Annotation Quickstart

Annotations are labels you can place on the data area of a plot. Unlike Text added to the plot (which is placed in coordinate units on the axes), Annotations are positioned relative to the data area (in pixel units) and do not move as the plot is panned and zoomed.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

myPlot.Add.Signal(Generate.Sin());
myPlot.Add.Signal(Generate.Cos());

myPlot.Add.Annotation("This is an Annotation");

myPlot.SavePng("demo.png", 400, 300);

Annotation Customization

Annotations can be extensively customized.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

myPlot.Add.Signal(Generate.Sin());
myPlot.Add.Signal(Generate.Cos());

var anno = myPlot.Add.Annotation("Customized\nAnnotation");
anno.Label.FontSize = 32;
anno.Label.FontName = Fonts.Serif;
anno.Label.BackColor = Colors.RebeccaPurple.WithAlpha(.3);
anno.Label.ForeColor = Colors.RebeccaPurple;
anno.Label.BorderColor = Colors.Green;
anno.Label.BorderWidth = 3;
anno.OffsetY = 40;
anno.OffsetX = 20;

myPlot.SavePng("demo.png", 400, 300);

Annotation Positions

Annotations are aligned with the data area.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

foreach (Alignment alignment in Enum.GetValues(typeof(Alignment)))
{
    myPlot.Add.Annotation(alignment.ToString(), alignment);
}

myPlot.SavePng("demo.png", 400, 300);