class_docstr: Legend guide
  
  Parameters
  ----------
  nrow : int, default=None
      Number of rows of legends.
  ncol : int, default=None
      Number of columns of legends.
  byrow : bool, default=False
      Whether to fill the legend row-wise or column-wise.
  keywidth : float, default=None
      Width of the legend key.
  keyheight : float, default=None
      Height of the legend key.
  kwargs : dict
      Parameters passed on to [](`~plotnine.guides.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 HPacker, TextArea, VPacker
  
      from .._mpl.offsetbox import ColoredDrawingArea
  
      obverse = slice(0, None)
      reverse = slice(None, None, -1)
      nbreak = len(self.key)
      _targets = self.theme._targets
  
      # 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_legend" not in _targets:
          _targets["legend_key"] = []
          _targets["legend_text_legend"] = []
  
      # title
      title_box = TextArea(self.title, textprops={"color": "black"})
      _targets["legend_title"].append(title_box)
  
      # labels
      labels = []
      for item in self.key["label"]:
          va = "center" if self.label_position == "top" else "baseline"
          ta = TextArea(item, textprops={"color": "black", "va": va})
          labels.append(ta)
          _targets["legend_text_legend"].extend(labels)
  
      # Drawings
      drawings = []
      for i in range(nbreak):
          da = ColoredDrawingArea(
              self._keywidth[i], self._keyheight[i], 0, 0, color="white"
          )
          # overlay geoms
          for gl in self.glayers:
              with suppress(IndexError):
                  data = gl.data.iloc[i]
                  da = gl.geom.draw_legend(data, da, gl.layer)
          drawings.append(da)
      _targets["legend_key"].append(drawings)
  
      # Match Drawings with labels to create the entries
      lookup = {
          "right": (HPacker, reverse),
          "left": (HPacker, obverse),
          "bottom": (VPacker, reverse),
          "top": (VPacker, obverse),
      }
      packer, slc = lookup[self.label_position]
      entries = []
      for d, l in zip(drawings, labels):
          e = packer(
              children=[l, d][slc],
              sep=self._label_margin,
              align="center",
              pad=0,
          )
          entries.append(e)
  
      # Put the entries together in rows or columns
      # A chunk is either a row or a column of entries
      # for a single legend
      if self.byrow:
          chunk_size, packers = self.ncol, [HPacker, VPacker]
          sep1 = self._legend_entry_spacing_x
          sep2 = self._legend_entry_spacing_y
      else:
          chunk_size, packers = self.nrow, [VPacker, HPacker]
          sep1 = self._legend_entry_spacing_y
          sep2 = self._legend_entry_spacing_x
  
      if self.reverse:
          entries = entries[::-1]
      chunks = []
      for i in range(len(entries)):
          start = i * chunk_size
          stop = start + chunk_size
          s = islice(entries, start, stop)
          chunks.append(list(s))
          if stop >= len(entries):
              break
  
      chunk_boxes = []
      for chunk in chunks:
          d1 = packers[0](children=chunk, align="left", sep=sep1, pad=0)
          chunk_boxes.append(d1)
  
      # Put all the entries (row & columns) together
      entries_box = packers[1](
          children=chunk_boxes, align="baseline", sep=sep2, pad=0
      )
  
      # Put the title and entries together
      packer, slc = lookup[self.title_position]
      children = [title_box, entries_box][slc]
      box = packer(
          children=children,
          sep=self._title_margin,
          align=self._title_align,
          pad=self._legend_margin,
      )
  
      return box
  
imports: from __future__ import annotations
  import hashlib
  import types
  import typing
  from contextlib import suppress
  from itertools import islice
  from warnings import warn
  import numpy
  import pandas
  from .._utils import SIZE_FACTOR, remove_missing
  from ..exceptions import PlotnineError, PlotnineWarning
  from ..geoms import geom_text
  from ..mapping.aes import rename_aesthetics
  from .guide import guide
label_desc: Use image node_id 6 for calling the guide_legend obj's underlying member method code with example usage: obj.draw() and returns: box