ScottPlot.NET
GitHub Repo stars

Inverted Palettes

Palettes can be inverted. Palettes that work well on light backgrounds typically work well on dark backgrounds if they are inverted.

ScottPlot.Plot myPlot = new();

var palette1 = new ScottPlot.Palettes.ColorblindFriendly();
var palette2 = palette1.Inverted();
var palette3 = palette1.InvertedHue();

for (int x = 0; x < palette1.Count(); x++)
{
    CoordinateRect rect1 = CoordinateRect.UnitSquare.WithTranslation(x, 4);
    CoordinateRect rect2 = CoordinateRect.UnitSquare.WithTranslation(x, 2);
    CoordinateRect rect3 = CoordinateRect.UnitSquare.WithTranslation(x, 0);
    var shape1 = myPlot.Add.Rectangle(rect1);
    var shape2 = myPlot.Add.Rectangle(rect2);
    var shape3 = myPlot.Add.Rectangle(rect3);

    // set color using the palette
    shape1.FillColor = palette1.Colors[x];
    shape2.FillColor = palette2.Colors[x];
    shape3.FillColor = palette3.Colors[x];

    shape1.LineColor = shape1.FillColor;
    shape2.LineColor = shape2.FillColor;
    shape3.LineColor = shape3.FillColor;

}

myPlot.Add.Text("Standard", 0, 5.5);
myPlot.Add.Text("Inverted", 0, 3.5);
myPlot.Add.Text("Inverted Hue", 0, 1.5);
myPlot.HideGrid();

myPlot.SavePng("demo.png", 400, 300);
This recipe is one of many in the Styling Plots category