The echemsuite.graphicaltools module

The Color class

class echemsuite.graphicaltools.Color(r, g, b)

Simple class encoding the basic properties of a color.

Parameters:
  • r (float) – The value of the red channel (float between 0 and 1)

  • g (float) – The value of the green channel (float between 0 and 1)

  • b (float) – The value of the blue channel (float between 0 and 1)

Raises:

ValueError – Exception raised if the arguments specified during construction does not match the valid color channel values.

property HEX: str

Returns the HEX string encodes the RGB values.

Returns:

The string encoding the HEX representation of the color.

Return type:

str

property RGB: Tuple[float, float, float]

Returns the tuple encoding the RGB values. (0<=value<=1)

Returns:

Returns the tuple encoding the RGB values.

Return type:

Tuple[float, float, float]

classmethod from_HEX(value)

Classmethod capable of constructing an instance of the Color class from an HEX string.

Parameters:

value (str) – The HEX string encoding the RGB colors.

Return type:

Color

saturate()

Saturate the color by setting the saturation channel to 1.

Returns:

An instance of the Color class encoding the saturated color.

Return type:

Color


The ColorShader class

class echemsuite.graphicaltools.ColorShader(basecolor, levels, reversed=False, saturate=False, luminance_range=(0.4, 0.9))

Simple class capable of providing shades of a given base color. The shades of color can be accessed by index using the built in __getitem__ method or can be obtained using the built in __iter__ method.

Parameters:
  • basecolor (Color) – The base color to be used in the generation of the shades

  • levels (int) – The number of color levels to be generated by the shader.

  • reversed (bool) – If set to True will reverse the order of the color shades.

  • saturate (bool) – If set to True will saturate the basecolor given as argument.

  • luminance_range (Tuple[float, float]) – The tuple encoding the minimum and maximum luminance values (between 0 and 1) used by the shader. (default:(0.4, 0.9))

Raises:

ValueError – Exception raised if an invalid number of levels has been provided by the user or if the luminance_range is invalid


The Palette class

class echemsuite.graphicaltools.Palette(palette)

A simple palette class capable of providing to the user different types color sequences. The __len__ attribute of the object is set as the length of the color sequence. The __getitem__ method allows the user to access the sequence of colors. If the index of the color exceeds the number of colors in the sequence the color provided will loop around the list.

The available palettes are: matplotlib, bold, pastel, prism, vivid

Parameters:

palette (str) – The name of the palette to be used.