Thecolorchanges/Python
0
1from typing import Dict, Tuple2 3import matplotlib.colors as mpl_colors4import seaborn as sns # type: ignore5 6# "darkorange", "purple", "cyan4"7colors = [[255, 140, 0], [160, 32, 240], [0, 139, 139]]8colors = [(r / 255.0, g / 255.0, b / 255.0) for r, g, b in colors]9 10palette: Dict[str, Tuple[float, float, float]] = {11 "Adelie": colors[0],12 "Chinstrap": colors[1],13 "Gentoo": colors[2],14 "default": sns.color_palette()[0], # type: ignore15}16 17bg_palette = {}18# Use `sns.set_style("whitegrid")` to help find approx alpha value19for name, col in palette.items():20 # Adjusted n_colors until `axe` accessibility did not complain about color contrast21 bg_palette[name] = mpl_colors.to_hex(sns.light_palette(col, n_colors=7)[1]) # type: ignore22 