Skip to content

Styling#

Apply styles, palettes, and gradients.

Sections defining various methods for defining and applying styles, such as color palettes and gradients.

Color#

Classes and methods for visualization color manipulation.

Classes and methods related to defining and manipulating colors within visualizations.

Single #

Single(color: Palette)

Class for creating a single color instance.

Create a class representing a single color within a palette for a Timeseries widget.

Constructor for Single.

Parameters:

Name Type Description Default
color Palette

a color from Palette.

required

DiscreteMap #

DiscreteMap(*items: DiscreteMapItem)

Map values to specific colors.

Construct a specification for creating a discrete map of colors. The DiscreteMap class allows users to define a set of DiscreteMapItem objects, each representing a mapping between a specific value or category and a corresponding color.

Constructor for DiscreteMap.

Parameters:

Name Type Description Default
items DiscreteMapItem

list of values, intervals composing the color map (DiscreteMapIntervalItem or DiscreteMapValueItem)

()

DiscreteMapValueItem #

DiscreteMapValueItem(
    value: Union[int, float], color: Union[Palette, Single]
)

Map single values to colors.

Create a specification to represent a discrete mapping between a single value and a specific color within a discrete color map.

Constructor for DiscreteMapValueItem.

Parameters:

Name Type Description Default
value Union[int, float]

value for which the color will be applied.

required
color Union[Palette, Single]

color applied to interval (Palette) or color itself (Single).

required

DiscreteMapIntervalItem #

DiscreteMapIntervalItem(
    *,
    min_value: Union[int, float],
    max_value: Union[int, float],
    color: Union[Palette, Single],
    exclude_min: bool = False,
    exclude_max: bool = False
)

Map value intervals to colors.

Define specifications for creating a color discrete map item, enabling association of a color with an interval of numerical values.

Constructor for DiscreteMapIntervalItem.

Parameters:

Name Type Description Default
min_value Union[int, float]

start of the interval.

required
max_value Union[int, float]

end of the interval.

required
color Union[Palette, Single]

color applied to interval (Palette) or color itself (Single).

required
exclude_min bool

whether to make min exclusive. (Default: False)

False
exclude_max bool

whether to make max exclusive. (Default: False)

False

Gradient #

Gradient(*items: GradientItem, steps: int = 10)

Define gradient for smooth transitions between colors.

Create a specification for defining a color gradient, allowing for smooth transitions between colors. The Gradient class facilitates the creation of a continuous range of colors by specifying a set of GradientItem objects representing key points along the gradient.

Constructor for Gradient.

Parameters:

Name Type Description Default
items GradientItem

map between color and intervals.

()
steps int

number of intermediate colors between gradient items. Defaults to 10.

10

GradientItem #

GradientItem(
    *,
    value: Union[int, float],
    color: Union[Palette, Single]
)

Represents value and corresponding color in a gradient.

Item within a color gradient, representing a value and its corresponding color. For instance suppose that a gradient has 3 colors, the Gradient class will have 3 GradientItem(s).

Constructor for GradientItem.

Parameters:

Name Type Description Default
value Union[int, float]

initial value of interval with color.

required
color Union[Palette, Single]

color applied to interval (Palette) or color itself (Single).

required

PositiveNegativeDiscreteMap #

PositiveNegativeDiscreteMap()

Template for discrete map with positive/negative numbers.

Template for creating a discrete map specifically designed for positive and negative numbers.

Constructor for PositiveNegativeDiscreteMap.

Palette#

qualitative_palette #

qualitative_palette(*, index: int) -> Palette

Returns color of qualitative palette given index.

Parameters:

Name Type Description Default
index int

index of qualitative palette (e.g. index of series of a timeseries chart)

required

Returns:

Name Type Description
Palette Palette

returns corresponding color of qualitative palette

sequential_palette #

sequential_palette(
    *,
    index: int,
    n_series: Optional[int] = None,
    palette: SequentialPaletteType = SequentialPalette
) -> Palette

Returns color of sequential palette given index.

Parameters:

Name Type Description Default
index int

index of sequential palette (e.g. index of series of a timeseries chart)

required
n_series Optional[int]

total number of series used for sequential palette. Determines sub-versions of sequential palette to improve contrast. Defaults to None, i.e. uses entire palette.

None
palette SequentialPaletteType

enum of sequential palettes to use.

SequentialPalette

Returns:

Name Type Description
Palette Palette

returns corresponding color of sequential palette

Palette #

Predefined color palettes.

Collection of predefined color palettes for various purposes.

PaletteTypes #

Selection of color palettes.

Selection of different types of color palettes available.

generate_color_mapping #

generate_color_mapping(
    *, length: int, color_method: _ColorMethod
) -> DiscreteMap

Generate color mapping by length, method.

Function to generate a color mapping based on specified parameters like length and color method.

ColorSpec module-attribute #

ColorSpec = Union[Palette, Single, Gradient, DiscreteMap]

Union type for color descriptions.

Union type representing various color descriptions including palettes, single colors, gradients, and discrete maps.