R/theme-flynn.R

Defines functions theme_flynn

Documented in theme_flynn

#' Custom ggplot2 theme
#'
#' This function creates a custom ggplot2 theme
#'
#' @inheritParams ggplot2::theme_grey
#' @author Michael E. Flynn
#'
#' @export
#' @importFrom ggplot2 %+replace%

theme_flynn <- function(base_size = 11, base_family = ""){

  theme_linedraw(base_size = base_size, base_family = base_family) %+replace%

    theme(plot.title = element_text(face = "bold", size = rel(1.4), hjust = 0, margin = margin(t = 0, b = 0.2, l = 0, r = 0, unit = "cm")),
          plot.title.position = "plot",
          plot.subtitle = element_text(size = rel(1.1), hjust = 0, margin = margin(b = 0.15, unit = "cm")),
          plot.subtitle.position = "plot",
          plot.caption = element_text(family = "roboto", face = "italic", size = rel(0.6), hjust = 1, margin = margin(t = 0, unit = "cm")),
          plot.caption.position = "plot",
          strip.background = element_rect(fill = "gray80", color = "black", size = 0.2),
          strip.text = element_text(size = rel(1), color = "black", face = "bold", margin = margin(t = 0.2, b = 0.2, l = 0.2, r = 0.2, unit = "cm")),
          panel.border = element_rect(fill = NA, size = 0.2),
          panel.background = element_rect(size = 0.2),
          panel.grid.major.y = element_line(color = "gray70", size = 0.15),
          panel.grid.minor.y = element_blank(),
          panel.grid.major.x = element_blank(),
          panel.grid.minor.x = element_blank(),
          axis.title = element_text(face = "bold", size = rel(1)),
          axis.title.y = element_text(angle = 90, margin = margin(t = 0, r = 0.5, b = 0, l = 0, unit = "cm")),
          axis.title.x = element_text(margin = margin(t = 0.5, r = 0, b = 0.3, l = 0, unit = "cm")),
          axis.ticks = element_line(size = 0.1),
          axis.ticks.length = unit(0.1, "cm"),
          legend.title = element_text(size = rel(1.1), face = "bold", hjust = 0, margin = margin(t = 0, b = 0.10, l = 0, r = 0, unit = "cm")),
          plot.margin = margin(0.5, 0.5, 0.5, 0.5, unit = "cm"))
}
meflynn/flynnprojects documentation built on April 17, 2025, 7:23 p.m.