ColorMap

class visualife.core.styles.ColorMap(stops, **kwargs)

Bases: object

A class that converts a real value into a color

The constructor creates a color map from given stops

Parameters:
  • stops (list of (float, color) tuples, color is str in HEX format or color name) – values and colors that defines stops in ColorMap object
  • kwargs – see below
Keyword Arguments (**kwargs)(**kwargs):
 
  • left_color (color) – a color assigned to values lover than the first stop color; by default the leftmost color is used
  • right_color (color) – a color assigned to values higher than the last stop color; by default the rightmost color is used
  • continuous_palette (bool) – if True creates a continuous color palette

Attributes Summary

left_color Returns a color assigned to values lover than the first stop color
max_value Returns the maximum value of this color scale.
min_value Returns the minimum value of this color scale.
right_color Returns a color assigned to values lover than the last stop color

Methods Summary

color(val) Returns an RGB color (as a string) for given value
color_tuple(val) Returns an RGB color (as a tuple of 3 integer components) for given value
continuous_color(val) Returns a color for given value
continuous_palette(pal, str]], <class >}[, s]) Retrun continuous color scale

Attributes Documentation

left_color

Returns a color assigned to values lover than the first stop color

max_value

Returns the maximum value of this color scale. All values higher than this one will be painted with self.right_color color

Returns:maximum value of this color scale
min_value

Returns the minimum value of this color scale. All values lower than this one will be painted with self.left_color color

Returns:minimum value of this color scale
right_color

Returns a color assigned to values lover than the last stop color

Methods Documentation

color(val) → str

Returns an RGB color (as a string) for given value

Parameters:val (float) – value for a color
color_tuple(val) → tuple

Returns an RGB color (as a tuple of 3 integer components) for given value

Parameters:val (tuple) – value for a color
continuous_color(val: float) → str

Returns a color for given value

Parameters:val (float) – value for a color
Returns:string in HEX format
static continuous_palette(pal: {typing.List[typing.Tuple[float, str]], <class 'object'>}, s=0.1) → Tuple[List[float], List[str]]

Retrun continuous color scale

Parameters:
  • pal (ColorMap object or list of (float, color) tuples, color is str in HEX format or color name) – discreet color palette
  • s (``float) – resolution
Returns:

tuple of two list, first holds values, second holds colors in HEX format