
Add only a continuous color legend to a gt table
gtscale_color_continuous.RdThis is a lower-level helper for cases where table coloring is already
handled elsewhere. For the usual "color and legendize" workflow, prefer
gtscale_data_color_continuous().
Usage
gtscale_color_continuous(
data,
column = NULL,
palette = NULL,
domain = NULL,
breaks = NULL,
labels = NULL,
title = NULL,
transform = NULL,
oob = NULL,
direction = "to right",
width = "160px",
height = "14px",
fn = NULL
)Arguments
- data
A
gt_tblcreated bygt::gt().- column
An optional numeric column in the underlying table used to infer
domain.- palette
A vector of colors used in the legend gradient. A single named palette or palette function can also be supplied.
- domain
A numeric vector of length 2 giving the scale limits. When omitted, the limits are inferred from
column.- breaks
Optional break values or a break function to display below the gradient.
- labels
An optional labeling function or a character vector for the breaks.
- title
Optional legend title.
- transform
A transformation specification understood by
scales::as.transform(). When omitted, an appropriate transform is inferred from the data.- oob
Out-of-bounds handling function or shortcut. Use a function like
scales::oob_squish()or a shortcut such as"censor","squish","keep", or"discard".- direction
CSS gradient direction. Defaults to
"to right".- width
Width of the legend bar.
- height
Height of the legend bar.
- fn
Backward-compatible fallback for passing a
scalespalette function.paletteis preferred.
Value
A modified gt::gt table.
Examples
library(gt)
exibble |>
gt() |>
data_color(
columns = num,
method = 'numeric',
palette = c('#A0442C', 'white', '#0063B1')
) |>
gtscale_color_continuous(
column = num,
palette = c('#A0442C', 'white', '#0063B1'),
title = 'Value'
)
num
char
fctr
date
time
datetime
currency
row
group
Value2,000,0004,000,0006,000,0008,000,000