.. _sphx_glr_auto_examples_plot_hue.py: ============================= Grouping data by category ============================= When plotting, its useful to have a way to color points by some category or variable. Hypertools does this using the `hue` kwarg, which takes a list of string category labels or numerical values. If text labels are passed, the data is restructured according to those labels and plotted in different colors according to your color palette. If numerical values are passed, the values are binned (default resolution: 100) and plotted according to your color palette. .. image:: /auto_examples/images/sphx_glr_plot_hue_001.png :align: center .. code-block:: python # Code source: Andrew Heusser # License: MIT # import import hypertools as hyp import numpy as np # load example data geo = hyp.load('weights_sample') data = geo.get_data() # simulate random groups hue=[] for idx,i in enumerate(data): tmp=[] for iidx,ii in enumerate(i): tmp.append(int(np.random.randint(1000, size=1))) hue.append(tmp) # plot geo.plot(fmt='.', hue=hue) **Total running time of the script:** ( 0 minutes 0.303 seconds) .. only :: html .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: plot_hue.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_hue.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_