In my project there is an opportunity to draw a graph for some data sets. Their number varies from 1 to ... until the user is bored with adding new data sets.

It is necessary that ALL lines are clearly visible on the graph. For this, it is necessary that all the lines be more or less contrasting with each other, as far as I understand.

The question is how to create these contrasting colors?

  • 2
    Here is an option with 10 colors: gamedev.stackexchange.com/questions/46463 - Kromster
  • one
    @ArtemGorlachev, well, in theory, when using pure randomness, very similar colors may still appear. - Ilya Bizunov
  • five
    Ilya, you were already correctly advised to start from the HSB model. You take the maximum saturation for each variant, on the color tone circle you choose several points at equal distances from each other. If you need more than six or seven colors, then you can take one point for two or three colors - and only vary the brightness. What kind of brightness values ​​to take is partly dependent on the background, then you just need to look and pick up two or three values. Well, and then the whole thing stupidly translate into RGB, formulas can google. - Xander
  • one
    As far as I know, there is no such possibility. You can ask the author comment to issue a response, or describe exactly how you solved the problem. - 4per
  • one
    a similar question: “Best” series of colors (note the colors in the picture in the most popular answer — this is not an error) - jfs

1 answer 1

On the advice of @ Kromster'a, I used this script :

for (int i = 0; i < 10; i++) colors[i] = HSV(0.1 * i, 0.5, 1.0); 

enter image description here

  • one
    @Kromster, updated the answer. - Ilya Bizunov