This function applies a custom theme to ggplot2 plots, incorporating specific fonts and colours to align with the institute's visual identity.
Usage
thekids_theme(
base_size = 11,
base_family = NULL,
base_line_size = base_size/22,
base_rect_size = base_size/22,
scale_colour_type = "discrete",
scale_fill_type = "discrete",
colour_theme = "viridis",
fill_theme = "viridis",
rev_colour = FALSE,
rev_fill = FALSE,
fig_dpi = 300,
...
)
theme_thekids(
base_size = 11,
base_family = NULL,
base_line_size = base_size/22,
base_rect_size = base_size/22,
scale_colour_type = "discrete",
scale_fill_type = "discrete",
colour_theme = "viridis",
fill_theme = "viridis",
rev_colour = FALSE,
rev_fill = FALSE,
fig_dpi = 300,
...
)
Arguments
- base_size
The base font size, given in points. Default is 11.
- base_family
The base font family used for the text (default Barlow). Most Google Fonts are supported (see Note).
- base_line_size
The base size for line elements (e.g., axis lines, grid lines). Calculated as
base_size/22
by default.- base_rect_size
The base size for rect elements (e.g., plot background, legend keys). Calculated as
base_size/22
by default.- scale_colour_type
Type of scale used for colours. Should be either
"discrete"
or"continuous"
. Default is"discrete"
.- scale_fill_type
Type of scale used for fills. Should be either
"discrete"
or"continuous"
. Default is"discrete"
.- colour_theme
Colour palette to use for colour scales. Must be one of
"viridis"
,"thekids"
,"thekids_tint"
,"thekids_grey"
. Default is"viridis"
.- fill_theme
Colour palette to use for fill scales. Must be one of
"viridis"
,"thekids"
,"thekids_tint"
,"thekids_grey"
. Default is"viridis"
.- rev_colour
Logical. Should the colour palette be reversed? Default is
FALSE
.- rev_fill
Logical. Should the fill palette be reversed? Default is
FALSE
.- fig_dpi
Base DPI for figure. Only applicable when Barlow font family (default) is not selected.
- ...
Miscellaneous arguments necessary for parameter aliasing, etc.
Details
The function determines the operating system and selects appropriate font names for Windows or other systems. It applies a minimal theme with custom settings for plot title, axis title, and strip text, using the 'Barlow Semi Condensed' font family. It also adjusts color scales using the 'viridis' package.
For a more thorough example, see the vignette.
Note
If a Google font has not been loaded with the package, thekids_theme
will load this function on your behalf.
Supported Google Fonts are those that exist in sysfonts::font_families_google()
.
Examples
if (FALSE) { # \dontrun{
# Install the required fonts first (see below)
# Example usage with ggplot2
library(ggplot2)
library(viridis)
p <- ggplot(mtcars, aes(x = mpg, y = wt, col = factor(cyl))) +
geom_point() +
thekids_theme()
print(p)
p2 <- ggplot(mtcars, aes(x = factor(cyl), y = wt, fill = factor(cyl))) +
geom_col() +
thekids_theme(fill_theme = "thekids_tint", rev_fill = T)
print(p2)
} # }
if (FALSE) { # \dontrun{
# Install the required fonts first (see below)
# Example usage with ggplot2
library(ggplot2)
library(viridis)
p <- ggplot(mtcars, aes(x = mpg, y = wt, col = factor(cyl))) +
geom_point() +
theme_thekids()
print(p)
p2 <- ggplot(mtcars, aes(x = factor(cyl), y = wt, fill = factor(cyl))) +
geom_col() +
theme_thekids(fill_theme = "thekids_tint", rev_fill = T)
print(p2)
} # }