Hacker News new | ask | show | jobs
by epaladin 4449 days ago
Can this create a palette of an arbitrary number of colors, or is it limited to six? I've been looking for a good way to generate an arbitrary number of visually distinct colors for a while, to use in visualizing high dimensional datasets in bioinformatics. The closest I've come so far is http://tools.medialab.sciences-po.fr/iwanthue/ (which is great but I need to port it to R one of these days)
3 comments

I have recently written a library that picks N as distinct possible from the RGB color space. Since RGB is not a perceptual color space, it measures distances between RGB colors in CIE Lab. Since the optimization of the most distinct color set can get stuck in local maxima, it uses simulated annealing for optimization.

One nice touch is that you can plug your own random RGB color generators that feed the optimizer, to find N distinct colors in a subspace of RGB. E.g., I use it to generate distinct pastel colors in visualization of linguistic data.

https://github.com/danieldk/quzah

(I am not an expert in this topic, but I couldn't find a good Java library with solid theoretical underpinnings.)

For arbitrarily many colors, use the golden ratio:

http://martin.ankerl.com/2009/12/09/how-to-create-random-col...

wow, this is great! I've been trying to find this for a while.

Their theory page (http://en.wikipedia.org/wiki/Lab_color_space) goes into how they do it, it's a pretty interesting approach of pre-calculating using CIE lab and then hcl for display/ui.

And the ui is well done, too.