facet_subsets

Contents

facet_subsets#

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

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

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

Parameters:
dataglue.core.data_collection.DataCollection

The DataCollection object to use

cidglue.core.component_id.ComponentID

The ComponentID to facet on

lofloat, optional

The lower bound for the faceting. Defaults to minimum value in data

hifloat, optional

The upper bound for the faceting. Defaults to maximum value in data

stepsint, optional

The number of subsets to create. Defaults to 5

prefixstr, optional

If present, the new subset labels will begin with prefix

logbool, optional

If True, space divisions logarithmically. Default is False

styledict, optional

Any visual attributes specified here will be used when creating subsets

cmapmatplotlib.colors.Colormap, optional

Matplotlib colormap instance used to generate colors. If specified, this will override any colors set in style

Returns:
subset_groupsiterable

List of glue.core.subset_group.SubsetGroup instances added to data

Examples

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].

facet_subset(data, data.id[‘mass’], lo=0, hi=10, steps=2, style=dict(alpha=0.5, markersize=5))

Performs the same faceting operation in the first example, but now each created subset will have an alpha of 0.5 and a marker size of 5.