class_docstr_tok: []
docstr: Construct and return a new ``ColorBar`` for this ``GlyphRenderer``.
  
  The function will check for a color mapper on an appropriate property
  of the GlyphRenderer's main glyph, in this order:
  
  * ``fill_color.transform`` for FillGlyph
  * ``line_color.transform`` for LineGlyph
  * ``text_color.transform`` for TextGlyph
  * ``color_mapper`` for Image
  
  In general, the function will "do the right thing" based on glyph type.
  If different behavior is needed, ColorBars can be constructed by hand.
  
  Extra keyword arguments may be passed in to control ``ColorBar``
  properties such as `title`.
  
  Returns:
      ColorBar
docstr_tok: ["Construct","and","return","a","new","``","ColorBar","``","for","this","``","GlyphRenderer","``",".","The","function","will","check","for","a","color","mapper","on","an","appropriate","property","of","the","GlyphRenderer","'s","main","glyph",",","in","this","order",":","*","``","fill_color.transform","``","for","FillGlyph","*","``","line_color.transform","``","for","LineGlyph","*","``","text_color.transform","``","for","TextGlyph","*","``","color_mapper","``","for","Image","In","general",",","the","function","will","``","do","the","right","thing","''","based","on","glyph","type",".","If","different","behavior","is","needed",",","ColorBars","can","be","constructed","by","hand",".","Extra","keyword","arguments","may","be","passed","in","to","control","``","ColorBar","``","properties","such","as","`","title","`",".","Returns",":","ColorBar"]
code: def construct_color_bar(self, **kwargs: Any) -> ColorBar:
      """Construct and return a new ``ColorBar`` for this ``GlyphRenderer``.
  
      The function will check for a color mapper on an appropriate property
      of the GlyphRenderer's main glyph, in this order:
  
      * ``fill_color.transform`` for FillGlyph
      * ``line_color.transform`` for LineGlyph
      * ``text_color.transform`` for TextGlyph
      * ``color_mapper`` for Image
  
      In general, the function will "do the right thing" based on glyph type.
      If different behavior is needed, ColorBars can be constructed by hand.
  
      Extra keyword arguments may be passed in to control ``ColorBar``
      properties such as `title`.
  
      Returns:
          ColorBar
  
      """
      from ...core.property.vectorization import Field
      from ..annotations import ColorBar
      from ..glyphs import (
          FillGlyph,
          Image,
          ImageStack,
          LineGlyph,
          TextGlyph,
      )
      from ..mappers import ColorMapper
  
      if isinstance(self.glyph, FillGlyph):
          fill_color = self.glyph.fill_color
          if not (
              isinstance(fill_color, Field)
              and isinstance(fill_color.transform, ColorMapper)
          ):
              raise ValueError(
                  "expected fill_color to be a field with a ColorMapper transform"
              )
          return ColorBar(color_mapper=fill_color.transform, **kwargs)
  
      elif isinstance(self.glyph, LineGlyph):
          line_color = self.glyph.line_color
          if not (
              isinstance(line_color, Field)
              and isinstance(line_color.transform, ColorMapper)
          ):
              raise ValueError(
                  "expected line_color to be a field with a ColorMapper transform"
              )
          return ColorBar(color_mapper=line_color.transform, **kwargs)
  
      elif isinstance(self.glyph, TextGlyph):
          text_color = self.glyph.text_color
          if not (
              isinstance(text_color, Field)
              and isinstance(text_color.transform, ColorMapper)
          ):
              raise ValueError(
                  "expected text_color to be a field with a ColorMapper transform"
              )
          return ColorBar(color_mapper=text_color.transform, **kwargs)
  
      elif isinstance(self.glyph, (Image, ImageStack)):
          return ColorBar(
              color_mapper=self.glyph.color_mapper, **kwargs
          )
  
      else:
          raise ValueError(
              f"construct_color_bar does not handle glyph type {type(self.glyph).__name__}"
          )
  
file_path: bokeh/src/bokeh/models/renderers/glyph_renderer.py
imports: from __future__ import annotations
  import logging
  from difflib import get_close_matches
  from typing import TYPE_CHECKING, Any, Literal
  from bokeh.core.property.vectorization import Field
  from ...core.properties import Auto, Bool, Either, Instance, InstanceDefault, Nullable, Required
  from ...core.validation import error
  from ...core.validation.errors import BAD_COLUMN_NAME, CDSVIEW_FILTERS_WITH_CONNECTED
  from ..filters import AllIndices
  from ..glyphs import ConnectedXYGlyph, Glyph
  from ..graphics import Decoration, Marking
  from ..sources import CDSView, ColumnDataSource, DataSource, WebDataSource
  from .renderer import DataRenderer
label_desc: Use image node_id 5 for calling the GlyphRenderer obj's underlying member method code with example usage: obj.construct_color_bar() and returns: ColorBar, ColorBar, ColorBar, ColorBar