Get Colors

Description

Returns the colors of the current color palette.

Usage

diverging_hcl.colors(n=11, fixup=None, alpha=None,
**kwargs)

Arguments

nint
Number of colors which should be returned.
fixupNone, bool
Should sRGB colors be corrected if they lie outside the defined color space? If None the fixup parameter from the object will be used. Can be set to True or False to explicitly control the fixup here.
alphaNone, float, list, or numpy.ndarray
Allows to add an transparency (alpha channel) to the colors. Can be a single float, a list, or a numpy array. If a list or array is provided it must be of length 1 or of length n and be convertible to float, providing values between 0.0 (full opacity) and 1.0 (full transparency)
**kwargs
Currently allows for rev = True to reverse the colors.

Return

list: Returns a list of str with n colors from the color palette.

Examples

from colorspace import diverging_hcl, hexcols
diverging_hcl().colors()
['#023FA5',
 '#5D6CAE',
 '#8C94BF',
 '#B3B7CF',
 '#D2D3DC',
 '#E2E2E2',
 '#DDD0D2',
 '#D2B0B6',
 '#C18692',
 '#AB5468',
 '#8E063B']
# Different diverging palette
cols = diverging_hcl("Green-Orange").colors(5)
cols
['#11C638', '#95D69A', '#E2E2E2', '#F0BC95', '#EF9708']
hexcols(cols)
  • #11C638
  • #95D69A
  • #E2E2E2
  • #F0BC95
  • #EF9708
# Five colors with constant alpha of 0.3
diverging_hcl().colors(5, alpha = 0.3)
['#023FA54D', '#A1A6C84D', '#E2E2E24D', '#CA9CA44D', '#8E063B4D']
# Three colors with variying alpha
diverging_hcl().colors(3, alpha = [0.2, 0.8, 0.3])
['#023FA533', '#E2E2E2CC', '#8E063B4D']