Is there a good algorithm for generating colors for use in graphs such as linear / beer / bar charts? Almost all charts have a built-in list of colors that they automatically assign to elements added to it. But sometimes you need to manually assign the colors yourself, in which case you will want to avoid manually setting the colors on their own, which is time consuming and probably will have poor results, while the algorithm can probably do it much better.
The generated colors should have the following properties:
Being easily differentiable from each other : as more and more elements are added, there is a chance of confusion and interpretation of errors. Therefore, it is important that the colors are as easily distinguishable from each other, especially colors that are close to each other in the color list. Conflicts are acceptable, although, obviously, it is preferable to avoid.
First, keep the classic colors : when there are several elements on the chart, it is advisable to first choose red, blue, dark, green, gray colors, but less easily distinguishable after.
Currently, I just use the color list that I found somewhere, and if I have more elements than the color list, the list is reused, which sometimes leads to color conflicts.
$default_colors = array(
"#4684ee", "#dc3912", "#ff9900", "#008000", "#666666",
"#4942cc", "#cb4ac5", "#d6ae00", "#336699", "#dd4477",
"#aaaa11", "#66aa00", "#888888", "#994499", "#dd5511",
"#22aa99", "#999999", "#705770", "#109618", "#a32929",
);
? , google-fu .