Add a centered title, subtitle, and legend to a gt
table with customizable label placement
Source: R/gt_centered_legend.R
gt_centered_legend.Rd
This function adds a centered title, subtitle, and a key or legend at the top
of a gt
table. The key/legend is passed through as a tibble containing
colors and labels. Labels can be placed either inside or outside the color
boxes.
Usage
gt_centered_legend(
gt_table,
key_info,
heading = "Centered Title",
subtitle = "Centered Subtitle",
label_placement = "outside"
)
Arguments
- gt_table
A
gt
table object to modify.- key_info
A tibble containing two columns:
color
(hex color codes) andlabel
(the corresponding text labels).- heading
Character. The main title text for the table. Defaults to
"Centered Title"
.- subtitle
Character. The subtitle text for the table. Defaults to
"Centered Subtitle"
.- label_placement
Character. Either
"inside"
or"outside"
, specifying whether the labels should be inside or outside the color boxes. Defaults to"outside"
.