Fills the cells of a tier column by tier level and bolds them, pairing each
level with a color. The remaining columns are rendered as images, since the
intended layout is a tier list with logos or headshots ranked into colored
bands.
Usage
gt_tiers(
gt_object,
levels,
colors = NULL,
style = "dark",
img_height = "55px",
tier_column = "tier",
image_columns = NULL
)Arguments
- gt_object
A
gttable object to modify.- levels
Character. The tier levels, matching the values in the table's tier column. May instead be a single named vector of
level = color, in which casecolorsis left unset. That is the same shapegt_legend_discrete()takes, so one object can drive both.- colors
Character. Hex color codes paired with
levels, in the same order. Must be the same length aslevels. Defaults toNULL, which requireslevelsto carry the colors as names.- style
Character. The color scheme, passed to
gt_theme_tier(). Either"dark"for a near-black ground or"light"for a white one. Defaults to"dark".- img_height
Character. The height of the images rendered in the image columns, as a CSS size. Defaults to
"55px".- tier_column
Character. The name of the column holding the tier levels. Defaults to
"tier".- image_columns
Optional. The columns to render as images. When
NULL, every column other thantier_columnis rendered as images. Defaults toNULL.
Details
The theme is applied once with gt_theme_tier(), the image columns are passed
through gt::fmt_image() at img_height, and all column labels are cleared,
so the input for those columns must be image paths or URLs. The function then
reduces over levels, and for each level fills the matching tier_column
cells with the paired color and sets their text to black or white, whichever
measures higher contrast against that fill, so each band keeps a legible
label. Naming image_columns leaves the rest untouched, so a text column can
sit alongside the images.
