A practitioner's method for choosing categorical colors, with color-blindness evaluators and an open-source tool
Summary by Mosaic, Designed's AI · may contain mistakes
Four years ago, I wrote “How to pick the least wrong colors.” The gist is: picking a categorical color palette is an optimization problem. There’s no such thing as the right colors. But if you use the right cost function, and the right kind of hill climbing, you can at least get the least wrong ones.
Since the original post I’ve been slowly picking away at improvements and new approaches. Now that we’re past the singularity, I’ve put a few coding robots on the job. It’s reassuring that many of my assumptions were good ones! The robots have been able to improve the code, bridging some of the gaps in my own knowledge.
Today, I’m publishing an updated version of the algorithm as an npm package, along with a fancy GUI version. While there’s still more to do, I’m proud of how far I’ve been able to take it.
What’s new
New evaluators
More controls
The public API and a CLI
What’s improved
The annealing algorithm
Configurable color space and distance metric
The results
One more thing
Acknowledgements
What’s new
New evaluators
Almost as soon as I published the first version, I realized that the cost function lends itself really well to modularity. Beyond my initial evaluation functions, I could design new ones, and provide a framework for anyone to plug in their own. As a recap, my original criteria for good categorical colors, mapped to evaluation functions:
Similarity — a way of measuring the similarity of one palette to another, useful for providing art direction and getting brand alignment
Energy — the colors should be different from each other so they aren’t liable to be confused with one another
Range — the differences between the colors should be consistent so unintended groupings don’t appear
Color vision deficiency — simulating the colors under different types of color blindness (red-green, blue-yellow, partial to full tritanopia)