Apply a color gradient to numeric columns in a GT object.
The gt_hulk_col_numeric() function takes an existing GT object and applies a color gradient to the background of specified numeric columns, based on their values. This is useful for visually emphasizing the distribution or magnitude of numeric data within a table.
Parameters
gt:GT
An existing GT object.
columns:SelectExpr=None
The columns to target. Can be a single column name or a list of column names. If None, the color gradient is applied to all columns.
palette:str | list[str]='PRGn'
The color palette to use for the gradient. Can be a string referencing a palette name or a list of color hex codes. Defaults to the "PRGn" palette from the ColorBrewer package.
domain:list[int] | list[float] | None=None
The range of values to map to the color palette. Should be a list of two values (min and max). If None, the domain is inferred from the data.
na_color:str | None=None
The color to use for missing (NA) values. If None, a default color is used.
alpha:int | float | None=None
The alpha (transparency) value for the colors, as a float between 0 (fully transparent) and 1 (fully opaque).
reverse:bool=False
If True, reverses the color palette direction.
autocolor_text:bool=True
If True, automatically adjusts text color for readability against the background.
Returns
:GT
The modified GT object, allowing for method chaining.