R/theme_cfeaR.R

#' Themes for Cape Fear
#'
#' @param base_size Text Font size. Default to 12.
#' @param base_family default to Poppins-Regular
#' @return
#' @export
#'

theme_cfeaR <- function (base_size = 12, base_family = "Poppins-Regular"){
  theme_grey(base_size = base_size, base_family = base_family) %+replace%
    theme(
      plot.title = element_text(size = 30, family = 'Oswald-SemiBold', color = '#14406A', hjust = 0, margin = margin(0, 0, 5, 0)),
      plot.title.position = "plot",

      plot.subtitle = element_text(size = 20, family = 'Oswald-SemiBold', color = '#66BBB7', hjust = 0, margin = margin(0, 0, 5, 0)),

      plot.caption = element_text(size = rel(0.8), family = 'Poppins-Light', color = '#373737', hjust = 1),
      plot.caption.position =  "plot",

      plot.margin = margin(2, 2, 2, 2, "cm"),

      axis.text = element_text(size = rel(0.8), family = 'Poppins-Light'),
      axis.ticks = element_line(colour = "black"),

      panel.background = element_rect(fill = "white", colour = NA),
      panel.border = element_rect(fill = NA, colour = "grey50"),

      panel.grid.major = element_line(colour = "grey90", size = 0.2),
      panel.grid.minor = element_line(colour = "grey98", size = 0.5),

      legend.key = element_rect(fill = "white", colour = "white"),
      legend.text = element_text(size = rel(0.8), family = 'Poppins-Light'),
      legend.title.align = 0.5,
      legend.box.background = element_rect(colour = "#14406A"))
}

# iris %>%
#   ggplot(aes(x = Petal.Length, y = Petal.Width, color = Species)) +
#   geom_point() +
#   theme_cfeaR() +
#   theme(
#     legend.position = c(.95, .05),
#     legend.justification = c("right", "bottom"),
#     legend.box.just = "right",
#     legend.margin = margin(6, 6, 6, 6)
#   ) +
#   scale_color_manual(values = group_col_cfeaR(n = 10)) +
#   labs(title = 'THIS IS AN EXAMPLE TITLE OF A GRAPH',
#        subtitle = 'This is the Subtitle',
#        caption = 'Source: Example of a Caption',
#        x = 'Title of X Axis',
#        y = 'Title of Y Axis')
# grid::grid.raster(image_read("./logos/Cape_Fear_Collective_Logo_Full_Horizontal2.png"),
#                   x = 0, y = 0, just = c('left', 'bottom'), width = unit(2, 'inches'))

# attempt at logo
# gg1 <-
#   iris %>%
#   ggplot(aes(x = Petal.Length, y = Petal.Width, color = Species)) +
#   geom_point() +
#   theme_cfeaR() +
#   theme(
#     legend.position = c(.95, .05),
#     legend.justification = c("right", "bottom"),
#     legend.box.just = "right",
#     legend.margin = margin(6, 6, 6, 6)
#   ) +
#   scale_color_manual(values = group_col_cfeaR(n = 10)) +
#   labs(title = 'THIS IS AN EXAMPLE TITLE OF A GRAPH',
#        subtitle = 'This is the Subtitle',
#        # caption = 'Source: Example of a Caption',
#        x = 'Title of X Axis',
#        y = 'Title of Y Axis')
#
# footer <- data.frame(
#   x = c(0, 1),
#   y = c(0, 0),
#   labels = c("", "Data source footnote")
# )
#
# gg2 <- ggplot(footer) +
#   geom_text(aes(x= x, y = y, label = labels), hjust = "inward") +
#   coord_cartesian(xlim = c(0,1)) +
#   theme(
#     plot.caption = element_text(size = rel(0.8), family = 'Poppins-Light', color = '#373737', hjust = 1),
#     plot.background = element_rect(fill = "#14406A"),
#     text = element_blank(),
#     line = element_blank(),
#     rect = element_blank()
#   )
#
# ggarrange(gg1, gg2, ncol = 1, nrow = 2, heights = c(10,1))
#
# grid::grid.raster(image_read("./logos/Cape_Fear_Collective_Logo_Full_Horizontal2-white.png"),
#                   x = 0, y = .2, just = c('left', 'bottom'), width = unit(2, 'inches'))
#
Cape-Fear-Collective/cfeaR documentation built on Sept. 3, 2020, 6:25 p.m.