ColorBarItem

class pyqtgraph.ColorBarItem(values=(0, 1), width=25, cmap=None, label=None, interactive=True, limits=None, rounding=1, orientation='vertical', pen='w', hoverPen='r', hoverBrush='#FF000080')[source]

Bases: PlotItem

ColorBarItem is a simpler, compact alternative to HistogramLUTItem, without histogram or the option to adjust the look-up table.

A labeled axis is displayed directly next to the gradient to help identify values. Handles included in the color bar allow for interactive adjustment.

A ColorBarItem can be assigned one or more ImageItems that will be displayed according to the selected color map and levels. The ColorBarItem can be used as a separate element in a GraphicsLayout or added to the layout of a PlotItem used to display image data with coordinate axes.

Signals:

sigLevelsChanged(self)

Emitted when the range sliders are moved

sigLevelsChangeFinished(self)

Emitted when the range sliders are released

__init__(values=(0, 1), width=25, cmap=None, label=None, interactive=True, limits=None, rounding=1, orientation='vertical', pen='w', hoverPen='r', hoverBrush='#FF000080')[source]

Create a new ColorBarItem.

Arguments:

values

The range of values as tuple (min, max)

width

(default=25) The width of the displayed color bar

cmap

ColorMap object, look-up table is also applied to assigned ImageItem(s)

label

(default=None) Label applied to color bar axis

interactive

(default=True) Handles are displayed to interactively adjust level range

limits

Limits to adjustment range as (low, high) tuple, None disables limit

rounding

(default=1) Adjusted range values are rounded to multiples of this values

orientation

(default=’vertical’) ‘horizontal’ gives a horizontal color bar

pen

color of adjustement handles in interactive mode

hoverPen

color of adjustement handles when hovered over

hoverBrush

color of movable center region when hovered over

levels()[source]

returns the currently set levels as the tuple (low, high).

setCmap(cmap)[source]

sets a ColorMap object to determine the ColorBarItem’s look-up table. The same look-up table is applied to any assigned ImageItem.

setImageItem(img, insert_in=None)[source]

assign ImageItem or list of ImageItems to be controlled

Arguments:

image

ImageItem or list of [ImageItem, ImageItem, …] that will be set to the color map of the ColorBarItem. In interactive mode, the levels of all assigned ImageItems will be controlled simultaneously.

insert_in

If a PlotItem is given, the color bar is inserted on the right or bottom of the plot

setLevels(values=None, low=None, high=None)[source]

Sets the displayed range of levels as specified.

Arguments:

values

Specify levels by tuple (low, high). Either value can be None to leave to previous value unchanged. Takes precedence over low and high parameters.

low

new low level to be applied to color bar and assigned images

high

new high level to be applied to color bar and assigned images