Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.3.0]

### Added
- Colorblind friendly Okabe-Ito color palette

## [2.2.0] - 2024-09-03

### Added
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Udo Liess
VisualMelon
vhoehn <veit.hoehn@hte-company.de>
Vsevolod Kukol <sevo@sevo.org>
Wim Leflere <wim.leflere@gmail.com>
Xavier <Xavier@xavier-PC.lsi>
zur003 <Eric.Zurcher@csiro.au>
Markus Ebner
Expand Down
23 changes: 23 additions & 0 deletions Source/Examples/ExampleLibrary/Misc/PaletteExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace ExampleLibrary
{
using OxyPlot;
using OxyPlot.Axes;

[Examples("Palettes")]
public class PaletteExamples
Expand Down Expand Up @@ -142,5 +143,27 @@ public static PlotModel Vertical_6()
{
return HeatMapSeriesExamples.CreatePeaks(OxyPalettes.Jet(6), false);
}

[Example("Okabe-Ito palette")]
public static PlotModel OkabeIto()
{
var model = new PlotModel
{
Title = "Okabe-Ito palette",
DefaultColors = OxyPalettes.OkabeIto8.Colors
};

model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });

foreach (var color in model.DefaultColors)
{
var lineSeries = LineSeriesExamples.CreateExampleLineSeries((int)color.ToUint());
lineSeries.Title = color.ToString().ToUpper().Replace("#FF", "#");
model.Series.Add(lineSeries);
}

return model;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ private static List<DataPoint> CreateRandomPoints(int numberOfPoints = 50)
/// Creates an example line series.
/// </summary>
/// <returns>A line series containing random points.</returns>
private static LineSeries CreateExampleLineSeries(int seed = 13)
public static LineSeries CreateExampleLineSeries(int seed = 13)
{
var lineSeries1 = new LineSeries();
var r = new Random(seed);
Expand Down
27 changes: 27 additions & 0 deletions Source/OxyPlot/Rendering/OxyPalettes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static OxyPalettes()
BlueWhiteRed31 = BlueWhiteRed(31);
Hot64 = Hot(64);
Hue64 = Hue(64);
OkabeIto8 = OkabeIto(8);
}

/// <summary>
Expand All @@ -39,6 +40,12 @@ static OxyPalettes()
/// </summary>
public static OxyPalette Hue64 { get; private set; }

/// <summary>
/// Gets the Okabe-Ito colorblind friendly palette with 8 colors.
/// https://jfly.uni-koeln.de/color/
/// </summary>
public static OxyPalette OkabeIto8 { get; private set; }

/// <summary>
/// Creates a black/white/red palette with the specified number of colors.
/// </summary>
Expand Down Expand Up @@ -165,5 +172,25 @@ public static OxyPalette Rainbow(int numberOfColors)
OxyColors.Orange,
OxyColors.Red);
}

/// <summary>
/// Creates the Okabe-Ito colorblind friendly palette with the specified number of colors.
/// https://jfly.uni-koeln.de/color/
/// </summary>
/// <param name="numberOfColors">The number of colors to create for the palette.</param>
/// <returns>A palette.</returns>
public static OxyPalette OkabeIto(int numberOfColors)
{
return OxyPalette.Interpolate(
numberOfColors,
OxyColor.FromRgb(0, 0, 0),
OxyColor.FromRgb(230, 159, 0),
OxyColor.FromRgb(86, 180, 233),
OxyColor.FromRgb(0, 158, 115),
OxyColor.FromRgb(240, 228, 66),
OxyColor.FromRgb(0, 114, 178),
OxyColor.FromRgb(213, 94, 0),
OxyColor.FromRgb(204, 121, 167));
}
}
}