#' ggplot theme with the AFB graphic layout
#'
#' @importFrom ggplot2 theme_minimal theme element_text
#'
#' @export
#'
theme_afb <- function(...) {
theme_minimal() +
theme(plot.title = element_text(colour = afb_cols("vert"), face = "bold"),
plot.caption = element_text(face = "italic"),
axis.title = element_text(colour = afb_cols("bleu"), hjust = 1, face = "bold"),
strip.text = element_text(colour = afb_cols("orange"), face = "bold", hjust = 0),
axis.line = element_line(),
axis.ticks = element_line(),
...)
}
# based on https://www.r-bloggers.com/creating-corporate-colour-palettes-for-ggplot2/
#' Function to extract afb colours as hex codes
#'
#' @param ... Character names of afb_colours
#'
#' @export
afb_cols <- function(...) {
afb_colours <- c(
`bleu` = "#39a9dc",
`vert` = "#8cc63f",
`orange`= "#f08b27",
`marron`= "#986338",
`gris` = "#7f8283",
`noir` = "#1a1516"
)
cols <- c(...)
if (is.null(cols))
return (afb_colours)
afb_colours[cols]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.