code: def table(
      ax,
      cellText=None,
      cellColours=None,
      cellLoc="right",
      colWidths=None,
      rowLabels=None,
      rowColours=None,
      rowLoc="left",
      colLabels=None,
      colColours=None,
      colLoc="center",
      loc="bottom",
      bbox=None,
      edges="closed",
      **kwargs,
  ):
      """
      TABLE(cellText=None, cellColours=None,
            cellLoc='right', colWidths=None,
            rowLabels=None, rowColours=None, rowLoc='left',
            colLabels=None, colColours=None, colLoc='center',
            loc='bottom', bbox=None, edges='closed')
  
      Factory function to generate a Table instance.
  
      Thanks to John Gill for providing the class and table.
      """
  
      if cellColours is None and cellText is None:
          raise ValueError(
              'At least one argument from "cellColours" or '
              '"cellText" must be provided to create a table.'
          )
  
      # Check we have some cellText
      if cellText is None:
          # assume just colours are needed
          rows = len(cellColours)
          cols = len(cellColours[0])
          cellText = [[""] * cols] * rows
  
      rows = len(cellText)
      cols = len(cellText[0])
      for row in cellText:
          if len(row) != cols:
              raise ValueError(
                  "Each row in 'cellText' must have {} columns".format(
                      cols
                  )
              )
  
      if cellColours is not None:
          if len(cellColours) != rows:
              raise ValueError(
                  "'cellColours' must have {} rows".format(rows)
              )
          for row in cellColours:
              if len(row) != cols:
                  raise ValueError(
                      "Each row in 'cellColours' must have {} "
                      "columns".format(cols)
                  )
      else:
          cellColours = ["w" * cols] * rows
  
      # Set colwidths if not given
      if colWidths is None:
          colWidths = [1.0 / cols] * cols
  
      # Fill in missing information for column
      # and row labels
      rowLabelWidth = 0
      if rowLabels is None:
          if rowColours is not None:
              rowLabels = [""] * rows
              rowLabelWidth = colWidths[0]
      elif rowColours is None:
          rowColours = "w" * rows
  
      if rowLabels is not None:
          if len(rowLabels) != rows:
              raise ValueError(
                  "'rowLabels' must be of length {0}".format(rows)
              )
  
      # If we have column labels, need to shift
      # the text and colour arrays down 1 row
      offset = 1
      if colLabels is None:
          if colColours is not None:
              colLabels = [""] * cols
          else:
              offset = 0
      elif colColours is None:
          colColours = "w" * cols
  
      # Set up cell colours if not given
      if cellColours is None:
          cellColours = ["w" * cols] * rows
  
      # Now create the table
      table = Table(ax, loc, bbox, **kwargs)
      table.edges = edges
      height = table._approx_text_height()
  
      # Add the cells
      for row in xrange(rows):
          for col in xrange(cols):
              table.add_cell(
                  row + offset,
                  col,
                  width=colWidths[col],
                  height=height,
                  text=cellText[row][col],
                  facecolor=cellColours[row][col],
                  loc=cellLoc,
              )
      # Do column labels
      if colLabels is not None:
          for col in xrange(cols):
              table.add_cell(
                  0,
                  col,
                  width=colWidths[col],
                  height=height,
                  text=colLabels[col],
                  facecolor=colColours[col],
                  loc=colLoc,
              )
  
      # Do row labels
      if rowLabels is not None:
          for row in xrange(rows):
              table.add_cell(
                  row + offset,
                  -1,
                  width=rowLabelWidth or 1e-15,
                  height=height,
                  text=rowLabels[row],
                  facecolor=rowColours[row],
                  loc=rowLoc,
              )
          if rowLabelWidth == 0:
              table.auto_set_column_width(-1)
  
      ax.add_table(table)
      return table
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  from six.moves import xrange
  import warnings
  from .None import artist
  from .artist import Artist, allow_rasterization
  from .patches import Rectangle
  from matplotlib import docstring
  from .text import Text
  from .transforms import Bbox
  from matplotlib.path import Path
label_desc: Use image node_id 1 for calling a global function with example usage: table(ax, cellText, cellColours, cellLoc, colWidths, rowLabels, rowColours, rowLoc, colLabels, colColours, colLoc, loc, bbox, edges) and returns: table