alan-turing-institute / distinctipy

A lightweight package for generating visually distinct colours.
https://distinctipy.readthedocs.io/en/latest/
MIT License
237 stars 13 forks source link

Ordering the colors generated #31

Closed bhavaygg closed 9 months ago

bhavaygg commented 10 months ago

Hello,

Thank you for your work. This library is of great help to me. I have a small suggestion. For many use cases, the labels and classes being visualized are ordered and it is better if the colors are ordered as well. When using distinctipy.get_colors(), it would be great if there is an option that the colors follow some order instead of being completely random.

jack89roberts commented 10 months ago

Hi @bhavaygg , thanks for your question. Could you help me understand what you mean exactly? Is what you want something more like one of the colormaps built-in to matplotlib? Or were you thinking of something like https://github.com/alan-turing-institute/distinctipy/issues/2, i.e. a feature that decides where to assign colours based on the positions of the classes/labels on the page?

The colours returned by distinctipy are ordered so that each colour in the list is as different as possible to all the previous colours. So the order is not strictly random (the difference between neighbouring colours will be more than random).

bhavaygg commented 10 months ago

Somewhat like the colormaps. I want to generate the N distinct colors but I don't mind if neighboring clusters are of similar colors, and the colors follow some sequence.

jack89roberts commented 10 months ago

If you want a sequence of ordered colours you may be better off making a list of colours from a matplotlib colormap, e.g. using something like this: https://stackoverflow.com/a/25408562

But if this doesn't cover your usecase let me know.

bhavaygg commented 9 months ago

Sorry, I understand this a bit better. My issues is kind of pointless. Thanks!. Closing.