Manual Legend Items Custom Font
Use custom fonts from TTF files in the legend (manual legend items).
ScottPlot.Plot myPlot = new();
// Add a font file to use its typeface for fonts with a given name
Fonts.AddFontFile(
name: "Alumni Sans",
path: Path.Combine(Paths.FontFolder, @"AlumniSans/AlumniSans-Regular.ttf"));
var sig1 = myPlot.Add.Signal(Generate.Sin(51));
sig1.LegendText = "Sin";
var sig2 = myPlot.Add.Signal(Generate.Cos(51));
sig2.LegendText = "Cos";
myPlot.Legend.ManualItems.Add(new LegendItem()
{
LabelText = "Custom",
LabelFontName = "Alumni Sans",
LabelFontSize = 18,
LabelFontColor = Colors.Magenta,
LinePattern = LinePattern.Dotted,
LineWidth = 2,
LineColor = Colors.Magenta,
});
myPlot.SavePng("demo.png", 400, 300);
This recipe is one of many in the Legends category
