ScottPlot.NET
GitHub Repo stars

Pie Slice Labels

Slice labels can be displayed centered with the slice at a customizable distance from the center of the pie.

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

PieSlice slice1 = new() { Value = 5, FillColor = Colors.Red, Label = "Red" };
PieSlice slice2 = new() { Value = 2, FillColor = Colors.Orange, Label = "Orange" };
PieSlice slice3 = new() { Value = 8, FillColor = Colors.Gold, Label = "Yellow" };
PieSlice slice4 = new() { Value = 4, FillColor = Colors.Green, Label = "Green" };
PieSlice slice5 = new() { Value = 8, FillColor = Colors.Blue, Label = "Blue" };
List<PieSlice> slices = new() { slice1, slice2, slice3, slice4, slice5 };

// setup the pie to display slice labels
var pie = myPlot.Add.Pie(slices);
pie.ExplodeFraction = .1;
pie.ShowSliceLabels = true;
pie.SliceLabelDistance = 1.3;

// styling can be customized for individual slices
slice5.LabelStyle.FontSize = 22;
slice5.LabelStyle.ForeColor = Colors.Magenta;
slice5.LabelStyle.Bold = true;

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

Edit on GitHub