I have some python Objects with some data in them, and all of them have an id ( 1,2,3,4,5 ..... n). I have a python function where I send one of these objects and I want to plot the data from it, and the color to be different based on the id. I tried to do some things i've seen from other questions, like trying to convert the id integer into an RGB value, like this:
Blue = integer & 255
Green = (integer >> 8) & 255
Red = (integer >> 16) & 255
return (RED/255, Green/255, Blue/255) # to get them into [0,1] interval
But the problem with that is that the color will be the same between close number like 1,2,3 (basicaly will have the same color almost). Any way to do this ?
EDIT:
So i was thinking of doing something like this:
def rgb_function(object_id):
random.seed(object_id)
value = random.uniform(0,1)
#then calculate RGB value based on this answer: https://stackoverflow.com/questions/55178857/convert-a-floating-point-number-to-rgb-vector
H = value;
R = abs(H * 6 - 3) - 1;
G = 2 - abs(H * 6 - 2);
B = 2 - abs(H * 6 - 4);
return max(0, min(1, R)), max(0, min(1, G)), max(0, min(1, B))