code: def andrews_curves(
      data,
      class_column,
      samples=200,
      alpha=None,
      width=450,
      height=300,
      **kwds,
  ):
      """
      Generates an Andrews curves visualization for visualising clusters of
      multivariate data.
  
      Andrews curves have the functional form:
  
      f(t) = x_1/sqrt(2) + x_2 sin(t) + x_3 cos(t) +
             x_4 sin(2t) + x_5 cos(2t) + ...
  
      Where x coefficients correspond to the values of each dimension and t is
      linearly spaced between -pi and +pi. Each row of frame then corresponds to
      a single curve.
  
      Parameters:
      -----------
      data : DataFrame
          Data to be plotted, preferably normalized to (0.0, 1.0)
      class_column : string
          Name of the column containing class names
      samples : integer
          Number of points to plot in each curve
      alpha: float, optional
          The transparency of the lines
      width : int, optional
          the width of the plot in pixels
      height : int, optional
          the height of the plot in pixels
      **kwds: keywords
          Additional options
  
      Returns:
      --------
      chart: alt.Chart object
  
      """
      if kwds:
          warnings.warn(
              "Unrecognized keywords in pdvega.andrews_curves(): {0}"
              "".format(list(kwds.keys()))
          )
  
      t = np.linspace(-np.pi, np.pi, samples)
      vals = data.drop(class_column, axis=1).values.T
  
      curves = np.outer(vals[0], np.ones_like(t))
      for i in range(1, len(vals)):
          ft = ((i + 1) // 2) * t
          if i % 2 == 1:
              curves += np.outer(vals[i], np.sin(ft))
          else:
              curves += np.outer(vals[i], np.cos(ft))
  
      df = pd.DataFrame(
          {
              "t": np.tile(t, curves.shape[0]),
              "sample": np.repeat(
                  np.arange(curves.shape[0]), curves.shape[1]
              ),
              " ": curves.ravel(),
              class_column: np.repeat(data[class_column], samples),
          }
      )
  
      chart = (
          alt.Chart(df)
          .properties(width=width, height=height)
          .mark_line()
      )
      chart = chart.encode(
          x=alt.X(field="t", type="quantitative"),
          y=alt.Y(field=" ", type="quantitative"),
          color=alt.Color(
              field=class_column,
              type=infer_vegalite_type(df[class_column]),
          ),
          detail=alt.Detail(field="sample", type="quantitative"),
      )
  
      if alpha is None and df[class_column].nunique() > 20:
          alpha = 0.5
  
      if alpha is not None:
          assert 0 <= alpha <= 1
          return chart.encode(opacity=alt.value(alpha))
  
      return chart
  
file_path: pdvega/pdvega/plotting.py
imports: import warnings
  import altair
  import numpy
  import pandas
  from ._utils import infer_vegalite_type
label_desc: Use image node_id 2 for calling a global function with example usage: andrews_curves(data, class_column, samples, alpha, width, height) and returns: chart, chart