ColorBarItem¶
- class pyqtgraph.ColorBarItem(values=(0, 1), width=25, colorMap=None, label=None, interactive=True, limits=None, rounding=1, orientation='vertical', pen='w', hoverPen='r', hoverBrush='#FF000080', cmap=None)[source]¶
Bases:
PlotItem
ColorBarItem
controls the application of a color map to one (or more)ImageItem
. It is a simpler, compact alternative toHistogramLUTItem
, without histogram or the option to adjust the colors of 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
GraphicsLayout
or added to the layout of aPlotItem
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, colorMap=None, label=None, interactive=True, limits=None, rounding=1, orientation='vertical', pen='w', hoverPen='r', hoverBrush='#FF000080', cmap=None)[source]¶
Creates a new ColorBarItem.
- Parameters
colorMap (str or
ColorMap
) – Determines the color map displayed and applied to assigned ImageItem(s).values (tuple of float) – The range of image levels covered by the color bar, as
(min, max)
.width (float, default=25) – The width of the displayed color bar.
label (str, optional) – Label applied to the color bar axis.
interactive (bool, default=True) – If True, handles are displayed to interactively adjust the level range.
limits (None or tuple of float) – Limits the adjustment range to (low, high), None disables the limit.
rounding (float, default=1) – Adjusted range values are rounded to multiples of this value.
orientation (str, default 'vertical') – ‘horizontal’ or ‘h’ gives a horizontal color bar instead of the default vertical bar
pen (
Qpen
or argument tomkPen()
) – Sets the color of adjustment handles in interactive mode.hoverPen (
QPen
or argument tomkPen()
) – Sets the color of adjustement handles when hovered over.hoverBrush (
QBrush
or argument tomkBrush()
) – Sets the color of movable center region when hovered over.
- setColorMap(colorMap)[source]¶
Sets a color map to determine the ColorBarItem’s look-up table. The same look-up table is applied to any assigned ImageItem.
colorMap can be a
ColorMap
or a string argument that is passed tocolormap.get()
.
- setImageItem(img, insert_in=None)[source]¶
Assigns an ImageItem or list of ImageItems to be represented and controlled
- Parameters
image (
ImageItem
or list of [ImageItem, ImageItem, …]) – Assigns one or more ImageItems to this ColorBarItem. If aColorMap
is defined for ColorBarItem, this will be assigned to the ImageItems. Otherwise, the ColorBarItem will attempt to retrieve a color map from the ImageItems. In interactive mode, ColorBarItem will control the levels of the assigned ImageItems, simultaneously if there is more than one.insert_in (
PlotItem
, optional) – If a PlotItem is given, the color bar is inserted on the right or bottom of the plot, depending on the specified orientation.
- setLevels(values=None, low=None, high=None)[source]¶
Sets the displayed range of image levels.
- Parameters
values (tuple of float) – Specifies levels as tuple
(low, high)
. Either value can be None to leave the previous value unchanged. Takes precedence over low and high parameters.low (float) – Applies a new low level to color bar and assigned images
high (float) – Applies a new high level to color bar and assigned images