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: Create the key for the guide
  
  The key is a dataframe with two columns:
  
  - scale name : values
  - label : labels for each value
  
  scale name is one of the aesthetics: `x`, `y`, `color`,
  `fill`, `size`, `shape`, `alpha`, `stroke`.
  
  Returns this guide if training is successful and None
  if it fails
docstr_tok: ["Create","the","key","for","the","guide","The","key","is","a","dataframe","with","two","columns",":","-","scale","name",":","values","-","label",":","labels","for","each","value","scale","name","is","one","of","the","aesthetics",":","`","x","`",",","`","y","`",",","`","color","`",",","`","fill","`",",","`","size","`",",","`","shape","`",",","`","alpha","`",",","`","stroke","`",".","Returns","this","guide","if","training","is","successful","and","None","if","it","fails"]
code: def train(self, scale, aesthetic=None):
      """
      Create the key for the guide
  
      The key is a dataframe with two columns:
  
      - scale name : values
      - label : labels for each value
  
      scale name is one of the aesthetics: `x`, `y`, `color`,
      `fill`, `size`, `shape`, `alpha`, `stroke`.
  
      Returns this guide if training is successful and None
      if it fails
      """
      if aesthetic is None:
          aesthetic = scale.aesthetics[0]
  
      breaks = scale.get_bounded_breaks()
      if not breaks:
          return None
  
      key = pd.DataFrame(
          {
              aesthetic: scale.map(breaks),
              "label": scale.get_labels(breaks),
          }
      )
  
      if len(key) == 0:
          return None
  
      self.key = key
  
      # create a hash of the important information in the guide
      labels = " ".join(str(x) for x in self.key["label"])
      info = "\n".join(
          [
              str(self.title),
              labels,
              str(self.direction),
              self.__class__.__name__,
          ]
      )
      self.hash = hashlib.sha256(info.encode("utf-8")).hexdigest()
      return self
  
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 1 for calling the guide_legend obj's underlying member method code with example usage: obj.train(scale, aesthetic) and returns: self, None, None