A custom ggplot2 theme for Charite – Universitaetsmedizin Berlin by Johannes Julius Mohn
Source:R/theme_charite.R
theme_charite.RdThis function creates a custom ggplot2 theme with customizable options for font, line thickness, grid, plot panel aspect ratio, and margins.
Usage
theme_charite(
font_size = 8,
thickness = 0.5,
font = "sans",
grid = FALSE,
aspect_ratio = 3/4,
tiny_margins = FALSE,
legend_key_size = NULL,
debug_area = FALSE
)Arguments
- font_size
Base font size in points like in your favourite text editor.
- thickness
Line thickness for axes. Default ggplot2 setting is 0.5.
- font
Character string for font family. Defaults to "sans" (ggplot2 default). Common alternatives: "Arial" or "Helvetica" in publications; "Calibri" suggested for Charite corporate identity; "Times New Roman", a timeless serif font. Note that the fonts must be installed on your OS to be used.
- grid
Logical; if TRUE, grid lines are added.
- aspect_ratio
Aspect ratio of the plot panel (y:x axis). Default is 3:4.
- tiny_margins
Logical; if TRUE, margins for all objects around the plot panel are minimized. Font rendering may depend on your system and the output format (PDF, PNG, SVG).
- legend_key_size
Size of the legend keys. Scales with font_size by default.
- debug_area
Visualize the plot margins for plot size debugging. Defaults to FALSE.
Details
To use a specific font, it must be installed on your operating system. Common fonts for figures include: "Arial" or "Helvetica" in publications and slides; "Calibri" is suggested for the Charite corporate identity. "Times New Roman" for contexts where legibility is aided by using a serif font.
Examples
library(ggplot2)
p <- ggplot(ChickWeight, aes(x = Time, y = weight, color = weight)) +
geom_point(size = 3) +
scale_color_charite("goldelse", discrete = FALSE) +
theme_charite()