Selecting Categorical Colors

Now we move from theory to practice. Let's say you're going to make a graph with twelve lines representing, say, the different months of the year. You'd like each line to be distinguishable from the others at a glance. Additionally, we'd like all of the colors to be visible on a dark or light background, so they can't be too dark or light themselves. This is the problem we're going to tackle with our new tools.

We have three spaces we can convert between as required

  • sRGB, the final output and the limits on our color choices.
  • Oklch, which lets us specify colors in familiar terms.
  • CAM16UCS, which gives us accurate color difference information.

People have tried a lot of methods to produce these color sets. Try to think of what you might consider right now, before you see my solution.

plot

Selecting Categorical Colors

Now we move from theory to practice. Let's say you're going to make a graph with twelve lines representing, say, the different months of the year. You'd like each line to be distinguishable from the others at a glance. Additionally, we'd like all of the colors to be visible on a dark or light background, so they can't be too dark or light themselves. This is the problem we're going to tackle with our new tools.

We have three spaces we can convert between as required

  • sRGB, the final output and the limits on our color choices.
  • Oklch, which lets us specify colors in familiar terms.
  • CAM16UCS, which gives us accurate color difference information.

People have tried a lot of methods to produce these color sets. Try to think of what you might consider right now, before you see my solution.

plot