class_docstr: This is a mixin class to support scalar -> RGBA mapping.  Handles
  normalization and colormapping
docstr: Return a normalized rgba array corresponding to *x*. If *x*
  is already an rgb array, insert *alpha*; if it is already
  rgba, return it unchanged. If *bytes* is True, return rgba as
  4 uint8s instead of 4 floats.
docstr_tok: ["Return","a","normalized","rgba","array","corresponding","to","*","x","*",".","If","*","x","*","is","already","an","rgb","array",",","insert","*","alpha","*",";","if","it","is","already","rgba",",","return","it","unchanged",".","If","*","bytes","*","is","True",",","return","rgba","as","4","uint8s","instead","of","4","floats","."]
code: def to_rgba(self, x, alpha=1.0, bytes=False):
      """Return a normalized rgba array corresponding to *x*. If *x*
      is already an rgb array, insert *alpha*; if it is already
      rgba, return it unchanged. If *bytes* is True, return rgba as
      4 uint8s instead of 4 floats.
      """
      try:
          if x.ndim == 3:
              if x.shape[2] == 3:
                  if x.dtype == np.uint8:
                      alpha = np.array(alpha * 255, np.uint8)
                  m, n = x.shape[:2]
                  xx = np.empty(shape=(m, n, 4), dtype=x.dtype)
                  xx[:, :, :3] = x
                  xx[:, :, 3] = alpha
              elif x.shape[2] == 4:
                  xx = x
              else:
                  raise ValueError("third dimension must be 3 or 4")
              if bytes and xx.dtype != np.uint8:
                  xx = (xx * 255).astype(np.uint8)
              return xx
      except AttributeError:
          pass
      x = ma.asarray(x)
      x = self.norm(x)
      x = self.cmap(x, alpha=alpha, bytes=bytes)
      return x
  
imports: import numpy
  from numpy import ma
  import matplotlib
  import matplotlib.colors
  import matplotlib.cbook
  from matplotlib._cm import *
label_desc: Use image node_id 3 for calling the ScalarMappable obj's underlying member method code with example usage: obj.to_rgba(x, alpha, bytes) and returns: x, xx