class_docstr: Guide colorbar
  
  Parameters
  ----------
  barwidth : float, default=None
      Width (in pixels) of the colorbar. If `None`, the
      [](`~plotnine.themes.themeable.legend_key_width`) is
      used. The value is multiplied by `1.45`.
  barheight : float, default=None
      Height (in pixels) of the colorbar.
      [](`~plotnine.themes.themeable.legend_key_height`) is
      used. The value is multiplied by `5 * 1.45`.
  nbin : int, default=20
      Number of bins for drawing a colorbar. A larger value yields
      a smoother colorbar
  raster : bool, default=False
      Whether to render the colorbar as a raster object.
  ticks : bool, default=True
      Whether tick marks on colorbar should be visible.
  draw_ulim : bool, default=True
      Whether to show the upper limit tick marks.
  draw_llim : bool, default=True
      Whether to show the lower limit tick marks.
  direction : Literal["horizontal", "vertical"], default="horizontal"
      Direction of the guide.
  kwargs : dict
      Parameters passed on to :class:`.guide`
class_docstr_tok: ["Guide","colorbar","Parameters","--","--","--","--","--","barwidth",":","float",",","default=None","Width","(","in","pixels",")","of","the","colorbar",".","If","`","None","`",",","the","[","]","(","`","~plotnine.themes.themeable.legend_key_width","`",")","is","used",".","The","value","is","multiplied","by","`","1.45","`",".","barheight",":","float",",","default=None","Height","(","in","pixels",")","of","the","colorbar",".","[","]","(","`","~plotnine.themes.themeable.legend_key_height","`",")","is","used",".","The","value","is","multiplied","by","`","5","*","1.45","`",".","nbin",":","int",",","default=20","Number","of","bins","for","drawing","a","colorbar",".","A","larger","value","yields","a","smoother","colorbar","raster",":","bool",",","default=False","Whether","to","render","the","colorbar","as","a","raster","object",".","ticks",":","bool",",","default=True","Whether","tick","marks","on","colorbar","should","be","visible",".","draw_ulim",":","bool",",","default=True","Whether","to","show","the","upper","limit","tick","marks",".","draw_llim",":","bool",",","default=True","Whether","to","show","the","lower","limit","tick","marks",".","direction",":","Literal","[","``","horizontal","''",",","``","vertical","''","]",",","default=","''","horizontal","''","Direction","of","the","guide",".","kwargs",":","dict","Parameters","passed","on","to",":","class",":","`",".guide","`"]
docstr: Draw guide
  
  Returns
  -------
  out : matplotlib.offsetbox.Offsetbox
      A drawing of this legend
docstr_tok: ["Draw","guide","Returns","--","--","--","-","out",":","matplotlib.offsetbox.Offsetbox","A","drawing","of","this","legend"]
code: def draw(self):
      """
      Draw guide
  
      Returns
      -------
      out : matplotlib.offsetbox.Offsetbox
          A drawing of this legend
      """
      from matplotlib.offsetbox import (
          DrawingArea,
          HPacker,
          TextArea,
          VPacker,
      )
  
      obverse = slice(0, None)
      reverse = slice(None, None, -1)
      nbars = len(self.bar)
      direction = self.direction
      colors = self.bar["color"].tolist()
      labels = self.key["label"].tolist()
      _targets = self.theme._targets
      _property = self.theme.themeables.property
  
      # 1.45 makes the default colourbar wider than the
      # legend entry boxes.
      width = (self.barwidth or _property("legend_key_width")) * 1.45
      height = (self.barheight or _property("legend_key_height")) * 1.45
  
      height *= 5
      length = height
  
      # When there is more than one guide, we keep
      # record of all of them using lists
      if "legend_title" not in _targets:
          _targets["legend_title"] = []
      if "legend_text_colorbar" not in _targets:
          _targets["legend_text_colorbar"] = []
  
      # .5 puts the ticks in the middle of the bars when
      # raster=False. So when raster=True the ticks are
      # in between interpolation points and the matching is
      # close though not exactly right.
      _from = self.bar["value"].min(), self.bar["value"].max()
      tick_locations = (
          rescale(self.key["value"], (0.5, nbars - 0.5), _from)
          * length
          / nbars
      )
  
      if direction == "horizontal":
          width, height = height, width
          length = width
  
      if self.reverse:
          colors = colors[::-1]
          labels = labels[::-1]
          tick_locations = length - tick_locations[::-1]
  
      # title #
      title_box = TextArea(self.title, textprops={"color": "black"})
      _targets["legend_title"].append(title_box)
  
      # colorbar and ticks #
      da = DrawingArea(width, height, 0, 0)
      if self.raster:
          add_interpolated_colorbar(da, colors, direction)
      else:
          add_segmented_colorbar(da, colors, direction)
  
      if self.ticks:
          _locations = tick_locations
          if not self.draw_ulim:
              _locations = _locations[:-1]
  
          if not self.draw_llim:
              _locations = _locations[1:]
  
          add_ticks(da, _locations, direction)
  
      # labels #
      if self.label:
          labels_da, legend_text = create_labels(
              da, labels, tick_locations, direction
          )
          _targets["legend_text_colorbar"].extend(legend_text)
      else:
          labels_da = DrawingArea(0, 0)
  
      # colorbar + labels #
      if direction == "vertical":
          packer, align = HPacker, "bottom"
          align = "center"
      else:
          packer, align = VPacker, "right"
          align = "center"
      slc = obverse if self.label_position == "right" else reverse
      if self.label_position in ("right", "bottom"):
          slc = obverse
      else:
          slc = reverse
      main_box = packer(
          children=[da, labels_da][slc],
          sep=self._label_margin,
          align=align,
          pad=0,
      )
  
      # title + colorbar(with labels) #
      lookup = {
          "right": (HPacker, reverse),
          "left": (HPacker, obverse),
          "bottom": (VPacker, reverse),
          "top": (VPacker, obverse),
      }
      packer, slc = lookup[self.title_position]
      children = [title_box, main_box][slc]
      box = packer(
          children=children,
          sep=self._title_margin,
          align=self._title_align,
          pad=0,
      )
      return box
  
imports: from __future__ import annotations
  import hashlib
  import typing
  from warnings import warn
  import numpy
  import pandas
  from mizani.bounds import rescale
  from ..exceptions import PlotnineWarning
  from ..mapping.aes import rename_aesthetics
  from ..scales.scale_continuous import scale_continuous
  from .guide import guide
label_desc: Use image node_id 4 for calling the guide_colorbar obj's underlying member method code with example usage: obj.draw() and returns: box