# CategoricalComponent¶

class glue.core.component.CategoricalComponent(categorical_data, categories=None, jitter=None, units=None)[source]

Container for categorical data.

Parameters: categorical_data – The underlying numpy.ndarray categories – List of unique values in the data Strategy for jittering the data

Attributes Summary

 categorical categories The categories. codes The index of the category for each value in the array. data labels The original categorical data. numeric

Methods Summary

 jitter([method]) Jitter the data so the density of points can be easily seen in a scatter plot. subset_from_roi(att, roi[, other_comp, …]) Create a SubsetState object from an ROI. to_series(**kwargs) Convert into a pandas.Series object.

Attributes Documentation

categorical[source]
categories[source]

The categories.

codes[source]

The index of the category for each value in the array.

data[source]
labels[source]

The original categorical data.

numeric[source]

Methods Documentation

jitter(method=None)[source]

Jitter the data so the density of points can be easily seen in a scatter plot.

Parameters: method – None | ‘uniform’:
• None: No jittering is done (or any jittering is undone).
• uniform: A unformly distributed random variable (-0.5, 0.5)
is applied to each point.
Returns: None
subset_from_roi(att, roi, other_comp=None, other_att=None, coord='x', is_nested=False)[source]

Create a SubsetState object from an ROI.

This encapsulates the logic for creating subset states with CategoricalComponents. There is an important caveat, only RangeROIs and RectangularROIs make sense in mixed type plots. As such, polygons are converted to their outer-most edges in this case.

Parameters: att – attribute name of this Component roi – an ROI object other_comp – The other Component for 2D ROIs other_att – The attribute name of the other Component coord – The orientation of this Component is_nested – True if this was passed from another Component. A SubsetState (or subclass) object
to_series(**kwargs)[source]

Convert into a pandas.Series object.

This will be converted as a dtype=np.object!

Parameters: kwargs – All kwargs are passed to the Series constructor. pandas.Series