plt.scatter(x1, y1, c=t, cmap=plt.cm.Spectral, linewidths=0)
ph = plt.plot(x1[0], y1[0], 'ko')

"""
Explanation: Plot original data with the t parameter corresponding to color
End of explanation
"""


compare_methods(X, 'Noisy spiral')

def make_circles(n_samples=100, shuffle=True, noise=None, random_state=None,
                 factors=[.8, 1.5, 2]):
    """Make a large circle containing a smaller circle in 2d.

    A simple toy dataset to visualize clustering and classification
    algorithms.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The total number of points generated.

    shuffle: bool, optional (default=True)
        Whether to shuffle the samples.

    noise : double or None (default=None)
        Standard deviation of Gaussian noise added to the data.

    factor : double < 1 (default=.8)
        Scale factor between inner and outer circle.

    Returns
    -------
    X : array of shape [n_samples, 2]
        The generated samples.

    y : array of shape [n_samples]
        The integer labels (0 or 1) for class membership of each sample.
    """

    # so as not to have the first point = last point, we add one and then
    # remove it.
    linspace = np.linspace(0, 2 * np.pi, n_samples + 1)[:-1]
    base_circ_x = np.cos(linspace)
    base_circ_y = np.sin(linspace)
    factor = factors[0]
    X = np.hstack(((factor * base_circ_x)[:, None], (factor * base_circ_y)[:, None]))
    y = np.zeros(n_samples)
    for idx, factor in enumerate(factors[1:]):
        inner_circ_x = base_circ_x * factor
        inner_circ_y = base_circ_y * factor
        X = np.vstack((X, np.hstack(((factor * base_circ_x)[:, None], (factor * base_circ_y)[:, None]))))
        y = np.hstack([y, (idx + 1) * np.ones(n_samples)])

    if not noise is None:
        X += np.random.normal(scale=noise, size=X.shape)

    return X, y

"""
Explanation: Compare diffusion embedding to spectral embedding (row 2)
In the case of diffusion embedding the diffusion time is being modified, while the number of components are being modified for spectral embedding. In the case of spectral embedding we are either using the default affinity (row 2).
End of explanation
"""


n_samples = 500
X, y = make_circles(n_samples=n_samples, factors=[1, 2, 3], noise=.1)
ed = (X - X[0, :])
ed = np.sqrt(np.sum(ed * ed , axis=1))
ed = ed/max(ed)

plt.subplot(121)
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Set1, linewidths=0)
plt.axis('tight')
plt.axis('equal')
plt.title('ring identity')
plt.subplot(122)
plt.scatter(X[:, 0], X[:, 1], c=ed, cmap=plt.cm.Spectral, linewidths=0)
plt.axis('tight')
plt.axis('equal')
plt.title('distance')
plt.colorbar()
ph = plt.plot(X[0, 0], X[0, 1], 'ko')

compare_methods(X, 'Concentric', cluster=3)

"""
Explanation: Plot the noisy circles
End of explanation
"""


