plastid.plotting.colors module

Utilities for manipulating colors and converting between representations as RGB hex strings, tuples of floats from 0.0 to 1.0, and tuples of ints from 0.0 to 255.

plastid.plotting.colors.darken(data, amt=0.1, is255=False)[source]

Darken a vector of colors by fraction amt of current intensity.

Parameters
datamatplotlib colorspec or sequence of colorspecs

input color(s)

amtfloat, optional

Percentage by which to darken r, g, and b. a remains unchanged (Default: 0.10)

Returns
numpy.ndarray

Lightened version of data

plastid.plotting.colors.get_rgb255(inp)[source]

Fetch r, g, b values where r, g, b are integers ranging from 0 to 255

Parameters
inpRGB or RGBA sequence or str

Can be color hex string, like “#007ADF”, a matplotlib color letter like “r”, a matplotlib color name like “black, et c.” See matplotlib.colors.colorConverter.to_rgb()

Returns
numpy.ndarray

Numpy array of r, g, b tuples where r, g, b take integer values from 0 to 255

plastid.plotting.colors.get_str_from_rgb(inp)[source]

Converts RGB tuples of floats from between 0.0 and 1.0 to RGB hex strings of type #RRGGBB

Parameters
inputtuple

Tuple of r, g, b values in range from 0.0 to 1.0

Returns
str

RGB hex string of form ‘#NNNNNN’

Raises
ValueError if values are out of range
plastid.plotting.colors.get_str_from_rgb255(inp)[source]

Converts RGB tuples of ints from between 0 and 255 to RGB hex strings of type #RRGGBB

Parameters
inputtuple

Tuple of r, g, b values in range from 0 to 255

Returns
str

RGB hex string of form ‘#NNNNNN’

Raises
ValueError if values are out of range
plastid.plotting.colors.lighten(data, amt=0.1, is255=False)[source]

Lighten a vector of colors by fraction amt of remaining possible intensity.

New colors are calculated as:

>>> new_colors = data + amt*(1.0 - data)
>>> new_colors[:, -1] = 1 # keep all alpha at 1.0
Parameters
datamatplotlib colorspec or sequence of colorspecs

input color(s)

amtfloat, optional

Percentage by which to lighten r, g, and b. a remains unchanged (Default: 0.10)

is255bool, optional

If True, rgb values in data are assumed to be tween 0 and 255 rather than 0.0 and 1.0. In this case, return values will also be between 0 and 255.

Returns
numpy.ndarray

Lightened version of data