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

Optionally always generate same color pallete #23

Closed Erol444 closed 2 years ago

Erol444 commented 2 years ago

Start with why

I believe this would be useful in AI field - where you have X number of classes as an output of an eg. object detection. In that case, it's much better to have bounding boxes with the same color each time you run the program - people get used to that color, so they don't need to look at the label of some object (to determine whether detector's output is correct).

Move to what:

Add an option to always get the same palette for the same number of colors.

End with how:

So it would be something similar to what seaborn does;

import seaborn
p = seaborn.color_palette("husl", 9)
# p will always be the same

Issue with seaborn is that it's huge and has tons of dependencies, which isn't ideal if you just want to get color palettes. If you are using random numbers to generate colors, maybe we could insert seed num for these, so the output color palette would always look the same.

Thoughts?

jack89roberts commented 2 years ago

Hi @Erol444 , thanks for using distinctipy! There are two ways to get the same colours on repeated runs:

Do these fit what you need?

Erol444 commented 2 years ago

Thanks @jack89roberts , that's exactly what I needed! Sometimes I should follow the RTFM rule 😅 Thanks again, Erik