Sujet : Re: good way to choose 15 colors? Or 20, more? (adjacent colors should look different)
De : HenHanna (at) *nospam* devnull.tb (HenHanna)
Groupes : comp.lang.pythonDate : 02. Jul 2024, 21:49:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v61ljv$1p0lj$2@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 7/2/2024 10:27 AM, DFS wrote:
On 7/2/2024 10:49 AM, HenHanna wrote:
>
black= (0,0,0)
white= (255,255, 255)
blue= (0, 0, 128)
pink= (245, 182, 193)
green= (0, 128, 0)
gray= (105,105, 105)
red= (128, 0,0)
yellow= (255, 255,0)
cyan= (0, 255, 255)
magenta= (255,0, 255)
purple= ( 160, 32, 240) ------------------ that's 11 colors
>
>
What's a good way to choose 15 colors? Or 20 colors? Or more?
1) choose from lists of predefined colors
https://www.rapidtables.com/web/color/RGB_Color.html
https://www.w3schools.com/html/html_colors_rgb.asp
https://excelatfinance.com/xlf/media/xlf-colindx2ws.png
2) predefine and name your own colors manually, then pick the colors at random from a list
3) generate random r,g,b values between 0 and 255, and name the resultant colors.
4) generate r,g,b values in ranges known to produce greens, reds, blues, oranges, yellows, etc. You could name them consecutively: green1, green2, green3...
> (adjacent colors should look different)
What are 'adjacent colors'?
black= (0,0,0)
white= (255,255,255) .............
from PIL import Image
from PIL import ImageDraw
def newImg():
img = Image.new('RGB', (120, 120))
for i in range(100):
img.putpixel((10+i,10+i), (red, black, white)[i%3])
img.save('test.gif')
return img
Thanks.... for what i mean by [adjacent] pls see above.
............good ways to choose 15, 20, or more colors in Python, ensuring adjacent colors look different:
1. Colormaps:
Import libraries:
Python
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
Choose a colormap:
There are many built-in colormaps in Matplotlib. Some that provide good visual distinction between adjacent colors include:
viridis
plasma
inferno
cividis
coolwarm (for diverging color schemes)