开发者

How to choose n different color automatically for plotting n different objects?

开发者 https://www.devze.com 2023-01-23 14:13 出处:网络
I need to draw n different objects on a chart. I want to pick a different color for each of them to make them distingui开发者_运维问答shable. The objects will be moved around, so I cannot count on ide

I need to draw n different objects on a chart. I want to pick a different color for each of them to make them distingui开发者_运维问答shable. The objects will be moved around, so I cannot count on ideas like "four color theorem" to assign same color to non-adjacent items. So far my problem call for up to 20 different items.

Is there a good way to pick n different colors to make them as distinguishable from each other as possible?


First of all, I have since changed the design so that it is not important to use 20 distinct colors. The default palette of 10 colors show up quite well.

Secondly, I've found an answer to my own question. The thing I want to do is called Color scale for categorical coding. Here is a paper that propose a method to do it

An algorithm for generating color scales for both categorical and ordinal coding - Breslow - 2009 - Color Research & Application - Wiley Online Library http://onlinelibrary.wiley.com/doi/10.1002/col.20559/full

I'm going to give the paper a glance. It is probably too technical than what I prepare to do.


I'd say colour distinction is a very subjective matter and you're probably better off looking for an existing colour palette and working your way from there. The higher your n, the higher your chance of two automatically generated colours being indistinguishable by your users even though by some colour-theoretic criterion they are very different.

And don't forget to make sure you don't use colour as the only distinction between objects, or:

  • you'll be in for a lot of hate mail from colour blind people
  • you risk people mistaking objects of similar colours as having some sort of implicit grouping


Do you really need to use 20 different colors? That is a lot of colors if you still want people to be able to distinguish them. Also realize that people who are colorblind will be lost looking at your charts. 10% of males are color blind. It would be better if you could further break down your objects into two to five groups. Then you could use different shapes as well as color to distinguish objects. For instance, you might have crosses, circles, triangles, stars, and squares of four different colors as shown here:

How to choose n different color automatically for plotting n different objects?

For choice of colors, I would check out the color brewer. However, notice it doesn't go up to 20 colors.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号