BandScale
The BandScale
class maps categorical values (strings) to evenly spaced positions within the output range. It allows configuration of inner padding and outer padding.
pydreamplet.scales.BandScale
BandScale(
domain: list[Any],
output_range: tuple[float, float],
padding: float = 0.1,
outer_padding: float | None = None
)
Parameters
domain
(list[Any]): A list of categorical values (distinct).output_range
(tuple[float, float]): The numeric output range.padding
(float, optional): The inner padding between bands (default: 0.1).outer_padding
(float, optional): The outer padding; defaults to the inner padding if not provided.
band = BandScale(["A", "B", "C"], (0, 300))
print(band.map("B")) # Outputs the start position for category "B"
print(band.bandwidth) # Width of each band
map
Returns the starting position of the band for the given categorical value.
bandwidth
Returns the computed width of each band.
domain
Get or set the list of categories.
output_range
Get or set the numeric output range.
padding
Get or set the inner padding.
outer_padding
Get or set the outer padding.