sanitizecolor(color, asarray=False, alpha=None, normalize=True)[source]#

Alias to matplotlib.colors.to_rgb(), but also handles numeric inputs.


color (str/list/etc): the input color to sanitize into an RGB tuple (or array) asarray (bool): whether to return an array instead of a tuple alpha (float): if not None, include the alpha channel with this value normalize (bool): whether to divide by 255 if any values are greater than 1


green1 = sc.sanitizecolor('g')
green2 = sc.sanitizecolor('tab:green')
crimson1 = sc.sanitizecolor('crimson')
crimson2 = sc.sanitizecolor((220, 20, 60))
midgrey = sc.sanitizecolor(0.5)