facet_subsets

glue.core.util.facet_subsets(data_collection, cid, lo=None, hi=None, steps=5, prefix='', log=False)[source]

Create a series of subsets that partition the values of a particular attribute into several bins

This creates steps new subet groups, adds them to the data collection, and returns the list of newly created subset groups.

Parameters:
  • data (ComponentID) – DataCollection object to use
  • cid – ComponentID to facet on
  • lo (float) – The lower bound for the faceting. Defaults to minimum value in data
  • hi (float) – The upper bound for the faceting. Defaults to maximum value in data
  • steps (int) – The number of subsets to create. Defaults to 5
  • prefix (str) – If present, the new subset labels will begin with prefix
  • log (bool) – If True, space divisions logarithmically. Default=False
Returns:

List of SubsetGroup instances added to data

Example:

facet_subset(data, data.id['mass'], lo=0, hi=10, steps=2)

creates 2 new subsets. The first represents the constraint 0 <= mass < 5. The second represents 5 <= mass <= 10:

facet_subset(data, data.id['mass'], lo=10, hi=0, steps=2)

Creates 2 new subsets. The first represents the constraint 10 >= x > 5 The second represents 5 >= mass >= 0:

facet_subset(data, data.id['mass'], lo=0, hi=10, steps=2, prefix='m')

Labels the subsets m_1 and m_2.

Note that the last range is inclusive on both sides. For example, if lo is 0 and hi is 5, and steps is 5, then the intervals for the subsets are [0,1), [1,2), [2,3), [3,4), and [4,5].