Skip to contents

This function creates a custom ggplot2 theme with customizable options for font, line thickness, grid, plot panel aspect ratio, and margins.

Usage

theme_sci(
  font_size = 8,
  thickness = 0.5,
  font = "sans",
  grid = FALSE,
  aspect_ratio = 1,
  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".

grid

Logical; if TRUE, grid lines are added.

aspect_ratio

Aspect ratio of the plot panel (y:x axis). Default is 1:1.

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.

Value

A ggplot2 theme

Details

To use a specific font, it must be installed on your operating system.

Examples

library(ggplot2)
p <- ggplot(ChickWeight, aes(x = Time, y = weight)) +
       geom_point() + theme_sci()