class_docstr: **Bases:** :class:`PlotItem <pyqtgraph.PlotItem>`
  
  :class:`ColorBarItem` controls the application of a 
  :ref:`color map <apiref_colormap>` to one (or more) 
  :class:`~pyqtgraph.ImageItem`. It is a simpler, compact alternative to 
  :class:`~pyqtgraph.HistogramLUTItem`, 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 :class:`~pyqtgraph.ImageItem` s 
  that will be displayed according to the selected color map and levels. The
  ColorBarItem can be used as a separate element in a 
  :class:`~pyqtgraph.GraphicsLayout` or added to the layout of a 
  :class:`~pyqtgraph.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
  =============================  =============================================
class_docstr_tok: ["*","*","Bases",":","*","*",":","class",":","`","PlotItem","<","pyqtgraph.PlotItem",">","`",":","class",":","`","ColorBarItem","`","controls","the","application","of","a",":","ref",":","`","color","map","<","apiref_colormap",">","`","to","one","(","or","more",")",":","class",":","`","~pyqtgraph.ImageItem","`",".","It","is","a","simpler",",","compact","alternative","to",":","class",":","`","~pyqtgraph.HistogramLUTItem","`",",","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",":","class",":","`","~pyqtgraph.ImageItem","`","s","that","will","be","displayed","according","to","the","selected","color","map","and","levels",".","The","ColorBarItem","can","be","used","as","a","separate","element","in","a",":","class",":","`","~pyqtgraph.GraphicsLayout","`","or","added","to","the","layout","of","a",":","class",":","`","~pyqtgraph.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","=============================","============================================="]
docstr: Creates a new ColorBarItem.
  
  Parameters
  ----------
  colorMap: `str` or :class:`~pyqtgraph.ColorMap`
      Determines the color map displayed and applied to assigned ImageItem(s).
  values: tuple of float, optional
      The range of values that will be represented by the color bar, as ``(min, max)``.
      If no values are supplied, the default is to use user-specified values from 
      an assigned image. If that does not exist, values will default to (0,1). 
  width: float, default=25.0
      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: `tuple of float`, optional
      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: :class:`QPen` or color_like
      Sets the color of adjustment handles in interactive mode.
  hoverPen: :class:`QPen` or color_like
      Sets the color of adjustment handles when hovered over.
  hoverBrush: :class:`QBrush` or color_like
      Sets the color of movable center region when hovered over.
docstr_tok: ["Creates","a","new","ColorBarItem",".","Parameters","--","--","--","--","--","colorMap",":","`","str","`","or",":","class",":","`","~pyqtgraph.ColorMap","`","Determines","the","color","map","displayed","and","applied","to","assigned","ImageItem","(","s",")",".","values",":","tuple","of","float",",","optional","The","range","of","values","that","will","be","represented","by","the","color","bar",",","as","``","(","min",",","max",")","``",".","If","no","values","are","supplied",",","the","default","is","to","use","user-specified","values","from","an","assigned","image",".","If","that","does","not","exist",",","values","will","default","to","(","0,1",")",".","width",":","float",",","default=25.0","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",":","`","tuple","of","float","`",",","optional","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",":",":","class",":","`","QPen","`","or","color_like","Sets","the","color","of","adjustment","handles","in","interactive","mode",".","hoverPen",":",":","class",":","`","QPen","`","or","color_like","Sets","the","color","of","adjustment","handles","when","hovered","over",".","hoverBrush",":",":","class",":","`","QBrush","`","or","color_like","Sets","the","color","of","movable","center","region","when","hovered","over","."]
code: def __init__(
      self,
      values=None,
      width=25,
      colorMap=None,
      label=None,
      interactive=True,
      limits=None,
      rounding=1,
      orientation="vertical",
      pen="w",
      hoverPen="r",
      hoverBrush="#FF000080",
  ):
      """
      Creates a new ColorBarItem.
  
      Parameters
      ----------
      colorMap: `str` or :class:`~pyqtgraph.ColorMap`
          Determines the color map displayed and applied to assigned ImageItem(s).
      values: tuple of float, optional
          The range of values that will be represented by the color bar, as ``(min, max)``.
          If no values are supplied, the default is to use user-specified values from
          an assigned image. If that does not exist, values will default to (0,1).
      width: float, default=25.0
          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: `tuple of float`, optional
          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: :class:`QPen` or color_like
          Sets the color of adjustment handles in interactive mode.
      hoverPen: :class:`QPen` or color_like
          Sets the color of adjustment handles when hovered over.
      hoverBrush: :class:`QBrush` or color_like
          Sets the color of movable center region when hovered over.
      """
      super().__init__()
      self.img_list = []  # list of controlled ImageItems
      self._actively_adjusted_values = False
      if values is None:
          # Use default values
          # NOTE: User-specified values from the assigned item will be preferred over the default values of ColorBarItem
          values = (0, 1)
      else:
          # The user explicitly entered values, prefer these over values from assigned image.
          self._actively_adjusted_values = True
      self.values = values
      self._colorMap = None
      self.rounding = rounding
      self.horizontal = bool(orientation in ("h", "horizontal"))
  
      (
          self.lo_prv,
          self.hi_prv,
      ) = self.values  # remember previous values while adjusting range
      self.lo_lim = None
      self.hi_lim = None
      if limits is not None:
          self.lo_lim, self.hi_lim = limits
          # slightly expand the limits to match the rounding steps:
          if self.lo_lim is not None:
              self.lo_lim = self.rounding * math.floor(
                  self.lo_lim / self.rounding
              )
          if self.hi_lim is not None:
              self.hi_lim = self.rounding * math.ceil(
                  self.hi_lim / self.rounding
              )
  
      self.disableAutoRange()
      self.hideButtons()
      self.setMouseEnabled(x=False, y=False)
      self.setMenuEnabled(False)
  
      if self.horizontal:
          self.setRange(xRange=(0, 256), yRange=(0, 1), padding=0)
          self.layout.setRowFixedHeight(2, width)
      else:
          self.setRange(xRange=(0, 1), yRange=(0, 256), padding=0)
          self.layout.setColumnFixedWidth(
              1, width
          )  # width of color bar
  
      for key in ["left", "right", "top", "bottom"]:
          self.showAxis(key)
          axis = self.getAxis(key)
          axis.setZValue(0.5)
          # select main axis:
          if self.horizontal and key == "bottom":
              self.axis = axis
          elif not self.horizontal and key == "right":
              self.axis = axis
              self.axis.setWidth(45)
          else:  # show other axes to create frame
              axis.setTicks([])
              axis.setStyle(showValues=False)
      self.axis.setStyle(showValues=True)
      self.axis.unlinkFromView()
      self.axis.setRange(self.values[0], self.values[1])
  
      if self.horizontal:
          if label is not None:
              self.getAxis("bottom").setLabel(label)
      else:
          if label is not None:
              self.getAxis("left").setLabel(label)
      self.bar = QtWidgets.QGraphicsPixmapItem()
      self.bar.setShapeMode(self.bar.ShapeMode.BoundingRectShape)
      self.addItem(self.bar)
      if colorMap is not None:
          self.setColorMap(colorMap)
  
      self.interactive = interactive
      if interactive:
          if self.horizontal:
              align = "vertical"
          else:
              align = "horizontal"
          self.region = LinearRegionItem(
              [63, 191],
              align,
              swapMode="block",
              # span=(0.15, 0.85),  # limited span looks better, but disables grabbing the region
              pen=pen,
              brush=fn.mkBrush(None),
              hoverPen=hoverPen,
              hoverBrush=hoverBrush,
          )
          self.region.setZValue(1000)
          self.region.lines[0].addMarker("<|>", size=6)
          self.region.lines[1].addMarker("<|>", size=6)
          self.region.sigRegionChanged.connect(self._regionChanging)
          self.region.sigRegionChangeFinished.connect(
              self._regionChanged
          )
          self.addItem(self.region)
          self.region_changed_enable = True
          self.region.setRegion(
              (63, 191)
          )  # place handles at 25% and 75% locations
      else:
          self.region = None
          self.region_changed_enable = False
  
file_path: pyqtgraph/pyqtgraph/graphicsItems/ColorBarItem.py
imports: import math
  import weakref
  import numpy
  from ..None import colormap
  from ..None import functions
  from ..Qt import QtCore, QtGui, QtWidgets
  from .LinearRegionItem import LinearRegionItem
  from .PlotItem import PlotItem
label_desc: Use image node_id 1 to create a new ColorBarItem object from inherited base classes: PlotItem with example: obj = ColorBarItem(values, width, colorMap, label, interactive, limits, rounding, orientation, pen, hoverPen, hoverBrush)