OrdinalScale
The OrdinalScale
class maps categorical values to a set of output values in a cyclic (repeating) fashion. This is useful for assigning properties like colors in order.
pydreamplet.scales.OrdinalScale
Parameters
domain
(list[Any]): A list of categorical values (distinct).output_range
(list): A list of output values (e.g., colors) to map to, which are reused cyclically.
ordinal = OrdinalScale(["apple", "banana", "cherry"], ["red", "yellow"])
print(ordinal.map("cherry")) # Output: "red" (wraps around)
map
Returns the mapped output value for the given domain value.
domain
Get or set the list of categories.
output_range
Get or set the list of output values.