This function adds a (custom styled) main title, y-axis label, and/or x-axis label as annotations to a Plotly figure, using RIVM theming and Dutch number formatting. It automatically calculates left margin spacing based on the longest y-axis label.
Usage
ro_ply_title(
fig,
y_data = NULL,
y_label = NULL,
x_label = NULL,
title = NULL,
base_family = "RijksoverheidSansWebText",
canvas_width = 776,
left_margin_base = 10,
char_width = 7,
title_size = 17,
axis_title_size = 13,
title_color = ro_color(color_name = "lintblauw"),
thousand_seperator = ".",
decimal_seperator = ","
)Arguments
- fig
A plotly figure object created by
plotly::plot_ly()to which the titles and labels will be added.- y_data
Used to determine the longest y-axis label for margin calculation.
- y_label
Y-axis label to display.
- x_label
X-axis label to display.
- title
Main title to display at the top left.
- base_family
Font family to use.
- canvas_width
Width of the plotting area in pixels.
- left_margin_base
Base left margin in pixels.
- char_width
Estimated width per character in pixels.
- title_size
Font size for the main title.
- axis_title_size
Font size for axis titles.
- title_color
Color for all titles/labels.
- thousand_seperator
Separator for thousands in y-axis labels.
- decimal_seperator
Separator for decimals in y-axis labels.
See also
Other plotly:
ro_ply_add_theme(),
ro_ply_cursor(),
ro_ply_dim(),
ro_ply_disable_toolbar(),
ro_ply_focus_linechart(),
ro_ply_keyboard_nav_barchart(),
ro_ply_keyboard_nav_bargraph(),
ro_ply_keyboard_nav_legend(),
ro_ply_keyboard_nav_linechart(),
ro_ply_keyboard_nav_trendline(),
ro_ply_legend_theme(),
ro_ply_theme()
Examples
if (FALSE) { # \dontrun{
# Title only:
ro_ply_title(fig, y_data = data$'Number of Cases', title = "Fancy title")
# Y-axis label only:
ro_ply_title(fig, y_label = "Number of cases")
# X-axis label only:
ro_ply_title(fig, x_label = "Groups")
# Title, Y-axis label, and X-axis label in one go:
ro_ply_title(fig, y_data = data$'Number of Cases',
y_label = "Number of cases", title = "Fancy title", x_label = "groups")
} # }
