HCL Based Rainbow Palette

Description

rainbow_hcl computes a rainbow of colors via qualitative_hcl defined by different hues given a single value of each chroma and luminance. It corresponds to rainbow which computes a rainbow in HSV space.

See also: qualitative_hcl, sequential_hcl, diverging_hcl, divergingx_hcl, heat_hcl, terrain_hcl, diverging_hsv, and rainbow.

Usage

rainbow_hcl(c=50, l=70, start=0,
end=<function rainbow_hcl.<lambda>>,
fixup=True, rev=False, *args, **kwargs)

Arguments

cfloat, int
Chroma (colorfullness) of the color map [0-100+].
lfloat, int
Luminance (lightness) of the color map [0-100].
startfloat, int, lambda
Hue at which the rainbow should start or lambda function with one argument. Defaults to 0.
endfloat, int, lambda
Hue (int) at which the rainbow should end or lambda function with one argument. By default a lambda function evaluated when drawing colors (360 * (n - 1) / n).
fixupbool
Only used when converting the HCL colors to hex. Should RGB values outside the defined RGB color space be corrected?
revbool
Should the color map be reversed? Default False.
*args
Currently unused.
**kwargs
Additional named arguments to overwrite the palette settings. Allowed: h1, h2, c1, l1, l2, p1.

Return

Initialize new object, no return. Raises a set of errors if the parameters are misspecified. Note that the object is callable, the default object call can be used to return hex colors (identical to the .colors() method), see examples.

Methods

rainbow_hcl.cmap(n=256, name='custom_hcl_cmap')
Create Matplotlib Compatible Color Map
rainbow_hcl.colors(n=11, fixup=None, alpha=None, **kwargs)
Get Colors
rainbow_hcl.get(key)
Get Specific Palette Setting
rainbow_hcl.hclplot(n=7, **kwargs)
Palette Plot in HCL Space
rainbow_hcl.name()
Get Palette Name
rainbow_hcl.show_settings()
Show Palette Settings
rainbow_hcl.specplot(n=180, *args, **kwargs)
Color Spectrum Plot
rainbow_hcl.swatchplot(n=7, **kwargs)
Palette Swatch Plot

Examples

from colorspace import rainbow_hcl
pal = rainbow_hcl()
pal.colors(10)
['#E495A5',
 '#D89F7F',
 '#BDAB66',
 '#96B56C',
 '#65BC8C',
 '#39BEB1',
 '#55B8D0',
 '#91ACE1',
 '#C29DDE',
 '#DE94C8']
pal.swatchplot(show_names = False, figsize = (5.5, 0.5));

# The standard call of the object also returns hex colors. Thus,
# you can make your code slimmer by calling
rainbow_hcl()(10)
['#E495A5',
 '#D89F7F',
 '#BDAB66',
 '#96B56C',
 '#65BC8C',
 '#39BEB1',
 '#55B8D0',
 '#91ACE1',
 '#C29DDE',
 '#DE94C8']
# Testing lambda function for both, start and end
pal = rainbow_hcl(start = lambda n: (n - 1) / n,
                  end   = lambda n: 360 - (n - 1) / n)
pal.swatchplot(n = 5, show_names = False, figsize = (5.5, 0.5))

pal.swatchplot(n = 10, show_names = False, figsize = (5.5, 0.5))