cmaps.py

Converts some nicer matplotlib colormaps to pyqtgraph colormaps.

class cmaps.PIVAColorMap[source]

Simple subclass of pyqtgraph.ColorMap. Adds vmax and powerlaw normalization gamma.

__init__(pos, color, mapping=ColorMap.CLIP)[source]

Parameters

pos: array_like of float, optional

Assigned positions of specified colors. None sets equal spacing. Values need to be in range 0.0-1.0.

color: array_like of color_like

List of colors, interpreted via mkColor().

mapping: str or int, optional

Controls how values outside the 0 to 1 range are mapped to colors. See setMappingMode() for details.

The default of ColorMap.CLIP continues to show the colors assigned to 0 and 1 for all values below or above this range, respectively.

Parameters:
Return type:

None

apply_transformations()[source]

Recalculate the positions where the colormapping is defined by applying (in sequence) alpha, then a linear map to the range [0, vmax] and finally the powerlaw scaling:

pos = pos^gamma
Return type:

None

set_gamma(gamma=1.0)[source]

Set the exponent for the power-law norm (gamma) that maps the colors to values. The values where the colours are defined are mapped like:

y = x^gamma
Parameters:

gamma (float)

Return type:

None

set_alpha(alpha)[source]

Set the value of alpha for the whole colormap to alpha where alpha can be a float or an array of length len(self.color).

Parameters:

alpha (float)

Return type:

None

set_vmax(vmax=1)[source]

Set the relative (to the maximum of the data) maximum of the colorscale.

Parameters:

vmax (float)

Return type:

None

cmaps.convert_matplotlib_to_pyqtgraph(matplotlib_cmap, alpha=0.5)[source]

Converts ColorMap object from matplotlib format to pyqtgraph format.

Parameters:
Returns:

corresponding colormap object in pyqtgrqph

Return type:

ColorMap

cmaps.convert_piva_to_matplotlib(piva_cmap, cmap_name='converted_cmap')[source]

Create a matplotlib colormap from a PIVAColorMap instance.

Parameters:
  • piva_cmap (PIVAColorMap) – colormap in a piva format

  • cmap_name (str) – optional name for the created cmap

Returns:

colormap in a matplotlib format

Return type:

LinearSegmentedColormap