Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions R/theme-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' legend titles, the plot title and tag text.
#' @param base_line_size base size for line elements
#' @param base_rect_size base size for rect elements
#' @param ink,paper colour for foreground and background elements respectively.
#' @param ink,paper,accent colour for foreground, background, and accented elements respectively.
#'
#' @details
#' \describe{
Expand Down Expand Up @@ -108,7 +108,7 @@ theme_grey <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {

# The half-line (base-fontsize / 2) sets up the basic vertical
# rhythm of the theme. Most margins will be set to this value.
Expand Down Expand Up @@ -157,7 +157,7 @@ theme_grey <- function(base_size = 11, base_family = "",
),

geom = element_geom(
ink = ink, paper = paper, accent = "#3366FF",
ink = ink, paper = paper, accent = accent,
linewidth = base_line_size, borderwidth = base_line_size,
linetype = 1L, bordertype = 1L,
family = base_family, fontsize = base_size,
Expand Down Expand Up @@ -288,15 +288,15 @@ theme_bw <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {
# Starts with theme_grey and then modify some parts
theme_grey(
base_size = base_size,
base_family = base_family,
header_family = header_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size,
ink = ink, paper = paper
ink = ink, paper = paper, accent = accent
) %+replace%
theme(
# white background and dark border
Expand All @@ -321,7 +321,7 @@ theme_linedraw <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {
half_line <- base_size / 2

# Starts with theme_bw and then modify some parts
Expand All @@ -332,7 +332,7 @@ theme_linedraw <- function(base_size = 11, base_family = "",
header_family = header_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size,
ink = ink, paper = paper
ink = ink, paper = paper, accent = accent
) %+replace%
theme(
# black text and ticks on the axes
Expand Down Expand Up @@ -365,7 +365,7 @@ theme_light <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {
half_line <- base_size / 2

# Starts with theme_grey and then modify some parts
Expand All @@ -375,7 +375,7 @@ theme_light <- function(base_size = 11, base_family = "",
header_family = header_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size,
ink = ink, paper = paper
ink = ink, paper = paper, accent = accent
) %+replace%
theme(
# white panel with light grey border
Expand Down Expand Up @@ -409,7 +409,7 @@ theme_dark <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {
half_line <- base_size / 2

# Starts with theme_grey and then modify some parts
Expand All @@ -419,7 +419,7 @@ theme_dark <- function(base_size = 11, base_family = "",
header_family = header_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size,
ink = ink, paper = paper
ink = ink, paper = paper, accent = accent
) %+replace%
theme(
# dark panel
Expand Down Expand Up @@ -451,15 +451,15 @@ theme_minimal <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {
# Starts with theme_bw and remove most parts
theme_bw(
base_size = base_size,
base_family = base_family,
header_family = header_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size,
ink = ink, paper = paper
ink = ink, paper = paper, accent = accent
) %+replace%
theme(
axis.ticks = element_blank(), # Extra margins due to absence ticks
Expand All @@ -484,14 +484,14 @@ theme_classic <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {
theme_bw(
base_size = base_size,
base_family = base_family,
header_family = header_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size,
ink = ink, paper = paper
ink = ink, paper = paper, accent = accent
) %+replace%
theme(
# no background and no grid
Expand All @@ -517,7 +517,7 @@ theme_void <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = alpha(ink, 0)) {
ink = "black", paper = alpha(ink, 0), accent = "#3366FF") {
half_line <- base_size / 2

# Only keep indispensable text: legend and plot titles
Expand All @@ -538,6 +538,13 @@ theme_void <- function(base_size = 11, base_family = "",
title = element_text(family = header_family),
spacing = unit(half_line, "pt"),
margins = margin_auto(half_line),
geom = element_geom(
ink = ink, paper = paper, accent = accent,
linewidth = base_line_size, borderwidth = base_line_size,
linetype = 1L, bordertype = 1L,
family = base_family, fontsize = base_size,
pointsize = (base_size / 11) * 1.5, pointshape = 19
),
axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks.length = rel(0),
Expand Down Expand Up @@ -608,7 +615,7 @@ theme_test <- function(base_size = 11, base_family = "",
header_family = NULL,
base_line_size = base_size / 22,
base_rect_size = base_size / 22,
ink = "black", paper = "white") {
ink = "black", paper = "white", accent = "#3366FF") {
half_line <- base_size / 2

t <- theme(
Expand Down Expand Up @@ -639,7 +646,7 @@ theme_test <- function(base_size = 11, base_family = "",
spacing = unit(half_line, "pt"),
margins = margin_auto(half_line),
geom = element_geom(
ink = ink, paper = paper, accent = "#3366FF",
ink = ink, paper = paper, accent = accent,
linewidth = base_line_size, borderwidth = base_line_size,
family = base_family, fontsize = base_size,
linetype = 1L,
Expand Down
Loading