code: def rainbowplot(
      data, xdata=None, depth=None, method="MBD", ax=None, cmap=None
  ):
      """
      Create a rainbow plot for a set of curves.
  
      A rainbow plot contains line plots of all curves in the dataset, colored in
      order of functional depth.  The median curve is shown in black.
  
      Parameters
      ----------
      data : sequence of ndarrays or 2-D ndarray
          The vectors of functions to create a functional boxplot from.  If a
          sequence of 1-D arrays, these should all be the same size.
          The first axis is the function index, the second axis the one along
          which the function is defined.  So ``data[0, :]`` is the first
          functional curve.
      xdata : ndarray, optional
          The independent variable for the data.  If not given, it is assumed to
          be an array of integers 0..N-1 with N the length of the vectors in
          `data`.
      depth : ndarray, optional
          A 1-D array of band depths for `data`, or equivalent order statistic.
          If not given, it will be calculated through `banddepth`.
      method : {'MBD', 'BD2'}, optional
          The method to use to calculate the band depth.  Default is 'MBD'.
      ax : AxesSubplot, optional
          If given, this subplot is used to plot in instead of a new figure being
          created.
      cmap : Matplotlib LinearSegmentedColormap instance, optional
          The colormap used to color curves with.  Default is a rainbow colormap,
          with red used for the most central and purple for the least central
          curves.
  
      Returns
      -------
      Figure
          If `ax` is None, the created figure.  Otherwise the figure to which
          `ax` is connected.
  
      See Also
      --------
      banddepth, fboxplot
  
      References
      ----------
      [1] R.J. Hyndman and H.L. Shang, "Rainbow Plots, Bagplots, and Boxplots for
          Functional Data", vol. 19, pp. 29-25, 2010.
  
      Examples
      --------
      Load the El Nino dataset.  Consists of 60 years worth of Pacific Ocean sea
      surface temperature data.
  
      >>> import matplotlib.pyplot as plt
      >>> import statsmodels.api as sm
      >>> data = sm.datasets.elnino.load()
  
      Create a rainbow plot:
  
      >>> fig = plt.figure()
      >>> ax = fig.add_subplot(111)
      >>> res = sm.graphics.rainbowplot(data.raw_data[:, 1:], ax=ax)
  
      >>> ax.set_xlabel("Month of the year")
      >>> ax.set_ylabel("Sea surface temperature (C)")
      >>> ax.set_xticks(np.arange(13, step=3) - 1)
      >>> ax.set_xticklabels(["", "Mar", "Jun", "Sep", "Dec"])
      >>> ax.set_xlim([-0.2, 11.2])
      >>> plt.show()
  
      .. plot:: plots/graphics_functional_rainbowplot.py
      """
      fig, ax = utils.create_mpl_ax(ax)
  
      if cmap is None:
          from matplotlib.cm import rainbow_r
  
          cmap = rainbow_r
  
      data = np.asarray(data)
      if xdata is None:
          xdata = np.arange(data.shape[1])
  
      # Calculate band depth if required.
      if depth is None:
          if method not in ["MBD", "BD2"]:
              raise ValueError("Unknown value for parameter `method`.")
  
          depth = banddepth(data, method=method)
      else:
          if depth.size != data.shape[0]:
              raise ValueError(
                  "Provided `depth` array is not of correct size."
              )
  
      ix_depth = np.argsort(depth)[::-1]
  
      # Plot all curves, colored by depth
      num_curves = data.shape[0]
      for ii in range(num_curves):
          ax.plot(
              xdata,
              data[ix_depth[ii], :],
              c=cmap(ii / (num_curves - 1.0)),
          )
  
      # Plot the median curve
      median_curve = data[ix_depth[0], :]
      ax.plot(xdata, median_curve, "k-", lw=2)
  
      return fig
  
file_path: statsmodels/statsmodels/graphics/functional.py
imports: from statsmodels.compat.numpy import NP_LT_123
  import numpy
  from scipy.special import comb
  from statsmodels.graphics.utils import _import_mpl
  from statsmodels.multivariate.pca import PCA
  from statsmodels.nonparametric.kernel_density import KDEMultivariate
  import itertools
  from multiprocessing import Pool
  from .None import utils
label_desc: Use image node_id 6 for calling a global function with example usage: rainbowplot(data, xdata, depth, method, ax, cmap) and returns: fig