Stable and Unique Colors for Category Labels

A method for defining a stable categorical color scale for real-time, changing data.

Base colors

Each color scale is initialized with a configurable number of base hues. There are 18 shown below. There are also several palettes available.

A sample list of categories

Each string is hashed to an integer, then mapped to one of the base hues above. If there is a collision, the color that is later in an alphabetical sort gets nudged a little darker or lighter to disambiguate. I would call it mostly stable, in that the same array of strings will always return the same colors, but the same individual string may shift a little depending on its peers.