ColorMap

class pyqtgraph.ColorMap(pos, color, mode=None)[source]

A ColorMap defines a relationship between a scalar value and a range of colors. ColorMaps are commonly used for false-coloring monochromatic images, coloring scatter-plot points, and coloring surface plots by height.

Each color map is defined by a set of colors, each corresponding to a particular scalar value. For example:

0.0 -> black
0.2 -> red
0.6 -> yellow
1.0 -> white

The colors for intermediate values are determined by interpolating between the two nearest colors in either RGB or HSV color space.

To provide user-defined color mappings, see GradientWidget.

__init__(pos, color, mode=None)[source]
Arguments:  
pos Array of positions where each color is defined
color Array of RGBA colors. Integer data types are interpreted as 0-255; float data types are interpreted as 0.0-1.0
mode Array of color modes (ColorMap.RGB, HSV_POS, or HSV_NEG) indicating the color space that should be used when interpolating between stops. Note that the last mode value is ignored. By default, the mode is entirely RGB.
getColors(mode=None)[source]

Return list of all color stops converted to the specified mode. If mode is None, then no conversion is done.

getGradient(p1=None, p2=None)[source]

Return a QLinearGradient object spanning from QPoints p1 to p2.

getLookupTable(start=0.0, stop=1.0, nPts=512, alpha=None, mode='byte')[source]

Return an RGB(A) lookup table (ndarray).

Arguments:  
start The starting value in the lookup table (default=0.0)
stop The final value in the lookup table (default=1.0)
nPts The number of points in the returned lookup table.
alpha True, False, or None - Specifies whether or not alpha values are included in the table. If alpha is None, it will be automatically determined.
mode Determines return type: ‘byte’ (0-255), ‘float’ (0.0-1.0), or ‘qcolor’. See map().
isMapTrivial()[source]

Return True if the gradient has exactly two stops in it: black at 0.0 and white at 1.0.

map(data, mode='byte')[source]

Return an array of colors corresponding to the values in data. Data must be either a scalar position or an array (any shape) of positions.

The mode argument determines the type of data returned:

byte (default) Values are returned as 0-255 unsigned bytes.
float Values are returned as 0.0-1.0 floats.
qcolor Values are returned as an array of QColor objects.
mapToByte(data)[source]

Convenience function; see map().

mapToFloat(data)[source]

Convenience function; see map().

mapToQColor(data)[source]

Convenience function; see map().

usesAlpha()[source]

Return True if any stops have an alpha < 255