-
Notifications
You must be signed in to change notification settings - Fork 1
/
tema_base.R
36 lines (36 loc) · 1.49 KB
/
tema_base.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#' Tema base
#'
#' This theme is designed to be a foundation from which to build new
#' themes, and not meant to be used directly. \code{theme_foundation()}
#' is a complete theme with only minimal number of elements defined.
#' It is easier to create new themes by extending this one rather
#' than \code{\link[ggplot2]{theme_gray}()} or \code{\link[ggplot2]{theme_bw}()},
#' because those themes define elements deep in the hierarchy.
#'
#' This theme takes \code{\link[ggplot2]{theme_gray}()} and sets all
#' \code{colour} and \code{fill} values to \code{NULL}, except for the top-level
#' elements (\code{line}, \code{rect}, and \code{title}), which have
#' \code{colour = "black"}, and \code{fill = "white"}. This leaves the spacing
#' and-non colour defaults of the default \pkg{ggplot2} themes in place.
#'
#' @inheritParams ggplot2::theme_grey
#'
#' @family themes
#' @export
#' @importFrom ggplot2 theme_grey
tema_base <- function(base_size=12, base_family="") {
thm <- theme_grey(base_size = base_size, base_family = base_family)
for (i in names(thm)) {
if ("colour" %in% names(thm[[i]])) {
thm[[i]]["color"] <- list(NULL)
}
if ("fill" %in% names(thm[[i]])) {
thm[[i]]["fill"] <- list(NULL)
}
}
thm + theme(panel.border = element_rect(fill = NA),
legend.background = element_rect(color = NA),
line = element_line(color = "black"),
rect = element_rect(fill = "white", color = NA),
text = element_text(color = "black"))
}