Visual Color Assigments
These manage the use of colors to ensure they are assigned uniquely to each feature and operator.
Functions to manage the selection of colors for the display of a Fuzzy Pattern Tree.
This module provides a flexible way to assign consistent colors to different entities (like features and operators) within a visualization, ensuring unique colors are assigned sequentially from a predefined or custom pool.
- class zuffy._visuals_color_assignment.ColorAssigner(color_pool: List[str])[source]
Bases:
objectA base class for assigning cyclical colors to named objects (e.g., features, operators).
This class manages a pool of colors and assigns a unique color from the pool to each new object_name it encounters. If an object_name has been seen before, it returns the previously assigned color. If the color pool is exhausted, it cycles back to the beginning of the pool. The assignment is consistent: the same object_name will always receive the same color once assigned.
Subclasses are expected to provide their specific default color pools.
- get_color(object_name: str) str[source]
Retrieves a color for a given object name.
If the object_name has been assigned a color before, that same color is returned. Otherwise, a new color is assigned from the internal color pool, cycling through the pool if necessary, and then returned.
Parameters
- object_namestr
The unique name of the object (e.g., a feature name, an operator string) for which to retrieve a color.
Returns
- str
The hexadecimal color code assigned to the object_name.
- class zuffy._visuals_color_assignment.FeatureColorAssigner(custom_colors: List[str] | None = None)[source]
Bases:
ColorAssignerManages color assignments specifically for feature objects.
Uses a distinct set of default colors suitable for features, which can be extended with user-provided colors.
- _DEFAULT_FEATURE_COLORS: List[str] = ['#4f77d4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
- class zuffy._visuals_color_assignment.OperatorColorAssigner(custom_colors: List[str] | None = None)[source]
Bases:
ColorAssignerManages color assignments specifically for operator objects.
Uses a distinct set of default colors suitable for operators, which can be extended with user-provided colors.
- _DEFAULT_OPERATOR_COLORS: List[str] = ['#f8ffef', '#f8ffff', '#fff8f8', '#fffff8', '#f8f8ff', '#eff8ff']