Colormap: Colormap API

This module provides the Colormap object

Colormap class

class silx.gui.plot.Colormap.Colormap(name='gray', colors=None, normalization='linear', vmin=None, vmax=None)[source]

Bases: PyQt4.QtCore.QObject

Description of a colormap

Parameters:
  • name (str) – Name of the colormap
  • colors (tuple) – optional, custom colormap. Nx3 or Nx4 numpy array of RGB(A) colors, either uint8 or float in [0, 1]. If ‘name’ is None, then this array is used as the colormap.
  • norm (str) – Normalization: ‘linear’ (default) or ‘log’
  • vmin (float) – Lower bound of the colormap or None for autoscale (default)
  • vmax (float) – Upper bounds of the colormap or None for autoscale (default)
LINEAR = 'linear'

constant for linear normalization

LOGARITHM = 'log'

constant for logarithmic normalization

NORMALIZATIONS = ('linear', 'log')

Tuple of managed normalizations

isAutoscale()[source]

Return True if both min and max are in autoscale mode

getName()[source]

Return the name of the colormap :rtype: str

setName(name)[source]

Set the name of the colormap and load the colors corresponding to the name

Parameters:name (str) – the name of the colormap (should be in [‘gray’, ‘reversed gray’, ‘temperature’, ‘red’, ‘green’, ‘blue’, ‘jet’, ‘viridis’, ‘magma’, ‘inferno’, ‘plasma’]
getColormapLUT()[source]

Return the list of colors for the colormap. None if not setted

Returns:the list of colors for the colormap. None if not setted
Return type:numpy.ndarray
setColormapLUT(colors)[source]

Set the colors of the colormap.

Parameters:colors (numpy.ndarray) – the colors of the LUT
getNormalization()[source]

Return the normalization of the colormap (‘log’ or ‘linear’)

Returns:the normalization of the colormap
Return type:str
setNormalization(norm)[source]

Set the norm (‘log’, ‘linear’)

Parameters:norm (str) – the norm to set
getVMin()[source]

Return the lower bound of the colormap

Returns:the lower bound of the colormap
Return type:float or None
setVMin(vmin)[source]

Set the minimal value of the colormap

Parameters:vmin (float) – Lower bound of the colormap or None for autoscale (default) value)
getVMax()[source]

Return the upper bounds of the colormap or None

Returns:the upper bounds of the colormap or None
Return type:float or None
setVMax(vmax)[source]

Set the maximal value of the colormap

Parameters:vmax (float) – Upper bounds of the colormap or None for autoscale (default)
getColormapRange(data=None)[source]

Return (vmin, vmax)

Returns:the tuple vmin, vmax fitting vmin, vmax, normalization and data if any given
Return type:tuple
setVRange(vmin, vmax)[source]

Set bounds to the colormap

Parameters:
  • vmin – Lower bound of the colormap or None for autoscale (default)
  • vmax – Upper bounds of the colormap or None for autoscale (default)
copy()[source]
Returns:a copy of the Colormap object
applyToData(data)[source]

Apply the colormap to the data

Parameters:data (numpy.ndarray) – The data to convert.
static getSupportedColormaps()[source]

Get the supported colormap names as a tuple of str.

The list should at least contain and start by: (‘gray’, ‘reversed gray’, ‘temperature’, ‘red’, ‘green’, ‘blue’) :rtype: tuple