| hd_opts | R Documentation |
Defines the visual presentation of a figure independently from the data
mapping. Pass the result as the opts argument of hd_make(), or omit
it to accept all defaults.
hd_opts(
title = NULL,
subtitle = NULL,
caption = NULL,
description = NULL,
xlab = " ",
ylab = " ",
ylim = NULL,
yint = 10,
ysuffix = NULL,
xtick_labels = NULL,
decimals = NULL,
flip = FALSE,
colors = NULL,
hc_theme = NULL,
gg_theme = NULL
)
title |
Character or |
subtitle |
Character or |
caption |
Character or |
description |
Character or
Write a concise one- or two-sentence summary of what the figure shows,
including the key trend or comparison, so the information is equally
accessible to users who cannot see the chart. Example:
|
xlab |
Character or
|
ylab |
Character or |
ylim |
Numeric vector of length 2 or |
yint |
Positive numeric. Y-axis tick interval. Default |
ysuffix |
Character or |
xtick_labels |
Character or |
decimals |
Integer or |
flip |
Logical. Invert axes (horizontal bars / inverted chart).
Default |
colors |
Character vector, palette name string, or |
hc_theme |
Character or |
gg_theme |
Character name string, ggplot2 theme object, or |
Because opts are separate from hd_spec(), the same data mapping can
be rendered with multiple styles without repetition:
spec <- hd_spec(df, "age", "pct", group = "sex") opts_en <- hd_opts(title = "Health survey", subtitle = "All ages") opts_no <- hd_opts(title = "Helseundersøkelse", subtitle = "Alle aldre") hd_make(spec, "column", opts_en) hd_make(spec, "column", opts_no)
An S3 object of class "hd_opts".
hd_spec(), hd_make(), hd_set_theme()
opts <- hd_opts(
title = "Health survey results",
subtitle = "Source: FHI 2024",
caption = "Tall om helse",
description = paste(
"Grouped bar chart showing alcohol use by age group and sex.",
"Use is highest in the 45-54 age group at 65% for women."
),
ylim = c(0, 100),
yint = 20,
colors = c("#025169", "#7C145C")
)
opts
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.