R/sarid_theme.R

Defines functions theme_sarid

Documented in theme_sarid

#' Apply a light theme on a ggplot with the Sarid theme.
#' Based on the theme_bw() layout, works similarly to theme().
#'
#'
#' @description The standard Sarid theme includes a re-coloring of certain plot elements
#'     with the Sarid color palette.
#'     The most notable difference is the strip background color and text color and
#'     the font sizes for titles and axis.
#'
#' @param ... Additional arguments passed to the theme function.
#'
#' @return An updated ggplot object rebranded to the Sarid look and feel.
#'
#' @examples
#' base_plot <- ggplot(mtcars, aes(x = disp, y = mpg, color = factor(cyl))) + geom_point()
#' base_plot + theme_sarid()
#' base_plot + theme_sarid() + facet_wrap(~vs)
#'
#' @export
theme_sarid <- function(...){

  # create the updated Sarid theme

  return_theme <- ggplot2::theme_bw() +
    ggplot2::theme(plot.title = ggplot2::element_text(color = "#0066ff", size = 15),
          plot.subtitle = ggplot2::element_text(color = "#3398ff", size = 13),
          plot.caption = ggplot2::element_text(color = "#3398ff"),
          axis.title = ggplot2::element_text(color = "#000000", size = 13),
          axis.text = ggplot2::element_text(color = "#000000", size = 12),
          strip.background = ggplot2::element_rect(fill = "#ffeca3"),
          strip.text = ggplot2::element_text(color = "#6D6E71", face = "bold"),
          panel.background = element_blank(),
          legend.background = element_blank())
    ggplot2::theme(...)

  return_theme

}
sarid-ins/saridr documentation built on Nov. 10, 2020, 9:07 p.m.