Skip to contents

Dark theme for a ggplot visualisation.

Usage

dark_mode(
  base_size = 10,
  base_family = "",
  base_face = "plain",
  base_pal = "#bbccdd",
  title_family = NULL,
  title_face = "bold",
  title_pal = NULL,
  title_size = ggplot2::rel(1.1),
  title_vjust = 0,
  title_margin = ggplot2::margin(t = base_size * -0.75, b = base_size * 2),
  subtitle_family = NULL,
  subtitle_face = NULL,
  subtitle_pal = NULL,
  subtitle_size = NULL,
  subtitle_vjust = 1,
  subtitle_margin = ggplot2::margin(t = base_size * -1, b = base_size + 10),
  caption_family = NULL,
  caption_face = NULL,
  caption_alpha = 0.33,
  caption_pal = base_pal,
  caption_size = ggplot2::rel(0.9),
  caption_hjust = 0,
  caption_vjust = 1,
  caption_margin = ggplot2::margin(t = base_size)
)

Arguments

base_size

The base size of the text. Defaults to 10.

base_family

The base family of the text. Defaults to "".

base_face

The base face of the text. Defaults to "plain".

base_pal

The base colour of the text. Defaults to "#bbccdd".

title_family

The font family of the title. Defaults to the base_family.

title_face

The font face of the title. Defaults to "bold".

title_pal

The colour of the title. Defaults to the base_pal first element.

title_size

The size of the title. Defaults to the base_size * 1.1.

title_vjust

The vertical adjustment of the title. Defaults to 0.

title_margin

The margin of the title. A ggplot2::margin function.

subtitle_family

The font family of the subtitle. Defaults to the base_family.

subtitle_face

The font face of the subtitle. Defaults to the base_face.

subtitle_pal

The colour of the subtitle. Defaults to the base_pal first element.

subtitle_size

The size of the subtitle. Defaults to the base_size.

subtitle_vjust

The vertical adjustment of the subtitle. Defaults to 1.

subtitle_margin

The margin of the subtitle. A ggplot2::margin function.

caption_family

The font family of the caption. Defaults to the base_family.

caption_face

The font face of the caption. Defaults to the base_face.

caption_alpha

The alpha of the caption pal. Defaults to 0.33. Use 1 for no alpha.

caption_pal

The colour of the caption (before caption_alpha is applied). Defaults to the base_pal first element.

caption_size

The size of the caption. Defaults to the base_size * 0.9.

caption_hjust

The horizontal adjustment of the caption. Defaults to 0.

caption_vjust

The vertical adjustment of the caption. Defaults to 1.

caption_margin

The margin of the caption. A ggplot2::margin function.

Value

A ggplot theme.

Examples

library(palmerpenguins)
library(ggplot2)

#set for a plot
penguins |>
  gg_point(
    x = flipper_length_mm,
    y = body_mass_g,
    col = species,
    theme = dark_mode()
  )
#> Warning: Removed 2 rows containing missing values (`geom_point()`).


#set globally
if (FALSE) {
  theme_set(dark_mode())

  penguins |>
    gg_point(
      x = flipper_length_mm,
      y = body_mass_g,
      col = species
    )
}