.. _sphx_glr_auto_examples_plot_clusters2.py: ============================= Using the cluster function to label clusters ============================= Here is an example where we generate some synthetic data, and then use the cluster function to get cluster labels, which we can then pass to the `hue` kwarg to color our points by cluster. .. image:: /auto_examples/images/sphx_glr_plot_clusters2_001.png :align: center .. code-block:: python # Code source: Andrew Heusser # License: MIT # import import hypertools as hyp import numpy as np from scipy.stats import multivariate_normal # simulate clusters cluster1 = np.random.multivariate_normal(np.zeros(3), np.eye(3), size=100) cluster2 = np.random.multivariate_normal(np.zeros(3)+3, np.eye(3), size=100) data = np.vstack([cluster1, cluster2]) # get cluster labels cluster_labels = hyp.cluster(data, n_clusters=2) # plot hyp.plot(data, '.', hue=cluster_labels) **Total running time of the script:** ( 0 minutes 0.093 seconds) .. only :: html .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: plot_clusters2.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_clusters2.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_