colorspace.qualitative_hcl

class colorspace.qualitative_hcl(h=[0, <function qualitative_hcl.<lambda>>], c=80, l=60, fixup=True, palette=None, rev=False, **kwargs)[source]

Qualitative HCL color palette.

Parameters:
  • h (float, int, or list) – Hue values defining the ‘color’. Qualitative color palettes require two hues. If more than two values are provided the first two will be used while the rest is ignored. If input h is a string this argument acts like the palette argument (see palette input parameter). Can also be lambda functions or a list of lambda functions which take up one single argument n (number of colors; see default value).

  • c (numeric) – Chroma value (colorfullness), a single numeric value. If multiple values are provided only the first one will be used.

  • l (numeric) – luminance value (lightness), a single numeric value. If multiple values are provided only the first one will be used.

  • fixup (bool) – Only used when converting the HCL colors to hex. Should RGB values outside the defined RGB color space be corrected?

  • palette (None, string) – Can be used to load a default diverging color qpalette specification. If the palette does not exist an exception will be qraised. Else the settings of the palette as defined will be used to create qthe color palette.

  • rev (bool) – Should the color map be reversed? Default False.

  • **kwargs – Additional arguments to overwrite the h/c/l settings. @TODO has to be documented.

See also

sequential_hcl, diverging_hcl, divergingx_hcl, rainbow_hcl, heat_hcl, terrain_hcl, diverging_hsv, and rainbow. All inherit from hclpalette.

Returns:

Initialize new object. 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.

Example

>>> from colorspace import diverging_hcl
>>> a = qualitative_hcl()
>>> a.colors(10)
>>> b = qualitative_hcl("Dynamic")
>>> b.colors(10)
>>> # The standard call of the object also returns hex colors. Thus,
>>> # you can make your code slimmer by calling:
>>> qualitative_hcl("Dynamic")(10)

Todo

Class does not allow for lambda function for h. Thus, the colors on both ends of a qualitative color map with h = [0, 360] are identical. See also palette definition (text files). I would need to allow for lambda functions which will require quite some adaptions of the current code (reading config files; _checkinput function; evaluation of the function whenever needed).

Just adding lambda. Write tests for this.

Raises:
  • TypeError – If h is not a single int or float, or a list (see next).

  • TypeError – If h is a list but not all elements are of type int, float, or callable (lambda functions).

Methods

__init__([h, c, l, fixup, palette, rev])

cmap([n, name])

Allows to retrieve a matplotlib LinearSegmentedColormap color map.

colors([n, fixup])

Returns the colors of the current color palette.

get(key)

Returns one specific item of the palette settings, e.g., the current value for h1 or l2.

name()

Get name of color palette.

show_settings()

Shows the current settings (table like print to stdout).

specplot([n])

Interfacing the colorspace.specplot.specplot() function.

swatchplot([n])

Interfacing the colorspace.swatchplot.swatchplot() function.