@deprecate_kwarg(old_arg_name='<STR_LIT:data>', new_arg_name='<STR_LIT>')<EOL>def andrews_curves(frame, class_column, ax=None, samples=<NUM_LIT:200>, color=None,<EOL>colormap=None, **kwds):
from math import sqrt, pi<EOL>import matplotlib.pyplot as plt<EOL>def function(amplitudes):<EOL><INDENT>def f(t):<EOL><INDENT>x1 = amplitudes[<NUM_LIT:0>]<EOL>result = x1 / sqrt(<NUM_LIT>)<EOL>coeffs = np.delete(np.copy(amplitudes), <NUM_LIT:0>)<EOL>coeffs.resize(int((coeffs.size + <NUM_LIT:1>) / <NUM_LIT:2>), <NUM_LIT:2>)<EOL>harmonics = np.arange(<NUM_LIT:0>, coeffs.shape[<NUM_LIT:0>]) + <NUM_LIT:1><EOL>trig_args = np.outer(harmonics, t)<EOL>result += np.sum(coeffs[:, <NUM_LIT:0>, np.newaxis] * np.sin(trig_args) +<EOL>coeffs[:, <NUM_LIT:1>, np.newaxis] * np.cos(trig_args),<EOL>axis=<NUM_LIT:0>)<EOL>return result<EOL><DEDENT>return f<EOL><DEDENT>n = len(frame)<EOL>class_col = frame[class_column]<EOL>classes = frame[class_column].drop_duplicates()<EOL>df = frame.drop(class_column, axis=<NUM_LIT:1>)<EOL>t = np.linspace(-pi, pi, samples)<EOL>used_legends = set()<EOL>color_values = _get_standard_colors(num_colors=len(classes),<EOL>colormap=colormap, color_type='<STR_LIT>',<EOL>color=color)<EOL>colors = dict(zip(classes, color_values))<EOL>if ax is None:<EOL><INDENT>ax = plt.gca(xlim=(-pi, pi))<EOL><DEDENT>for i in range(n):<EOL><INDENT>row = df.iloc[i].values<EOL>f = function(row)<EOL>y = f(t)<EOL>kls = class_col.iat[i]<EOL>label = pprint_thing(kls)<EOL>if label not in used_legends:<EOL><INDENT>used_legends.add(label)<EOL>ax.plot(t, y, color=colors[kls], label=label, **kwds)<EOL><DEDENT>else:<EOL><INDENT>ax.plot(t, y, color=colors[kls], **kwds)<EOL><DEDENT><DEDENT>ax.legend(loc='<STR_LIT>')<EOL>ax.grid()<EOL>return ax<EOL>
Generate a matplotlib plot of Andrews curves, 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
----------
frame : DataFrame
    Data to be plotted, preferably normalized to (0.0, 1.0)
class_column : Name of the column containing class names
ax : matplotlib axes object, default None
samples : Number of points to plot in each curve
color : list or tuple, optional
    Colors to use for the different classes
colormap : str or matplotlib colormap object, default None
    Colormap to select colors from. If string, load colormap with that name
    from matplotlib.
kwds : keywords
    Options to pass to matplotlib plotting method

Returns
-------
class:`matplotlip.axis.Axes`