R/theme_report.R

Defines functions theme_report

Documented in theme_report

#' Set figure theme for reports
#'
#' @param base_size
#' @param base_family
#'
#' @return
#' @export theme_report
#'
#' @importFrom ggplot2 element_blank
#' @importFrom ggplot2 element_line
#' @importFrom ggplot2 element_rect
#' @importFrom ggplot2 element_text
#'
#' @examples
#'
#'theme_report(base_size = 11, base_family = "Times")
#'
#'Other fonts are available, though sans font is
#'the easiest to implement using the following.
#'
#'theme_report(base_family = "")
#'
#'Updating font size is accomplished by changing the base_size.
#'
#'theme_report(base_size = 20, base_family = "")
#'
theme_report <- function(base_size = 11, base_family = "Times") {

  windowsFonts(Times=windowsFont("TT Times New Roman"))

  half_line <- base_size/2

  ggplot2::theme_light(base_size = base_size, base_family = base_family) +
    ggplot2::theme(
      panel.grid.major = ggplot2::element_blank(),
      panel.grid.minor = ggplot2::element_blank(),
      axis.ticks.length = grid::unit(half_line / 2.2, "pt"),
      strip.background = ggplot2::element_rect(fill = NA, colour = NA),
      strip.text.x = element_text(colour = "black"),
      strip.text.y = element_text(colour = "black"),
      panel.border = element_rect(fill = NA),
      legend.key.size = grid::unit(0.9, "lines"),
      legend.key = ggplot2::element_rect(colour = NA, fill = NA),
      legend.background = ggplot2::element_rect(colour = NA, fill = NA)
    )
}
ben-williams/funcr documentation built on Nov. 19, 2020, 8:06 a.m.