theme_minimal_white: Minimal Theme with White Background and Custom Axis/Grid...

View source: R/theme_minimal_white.R

theme_minimal_whiteR Documentation

Minimal Theme with White Background and Custom Axis/Grid Options

Description

This function extends ggplot2::theme_minimal() by ensuring a white background (preventing gray backgrounds when exporting to PNG) and providing options for customizing axis lines, grid visibility, axis ticks, and borders.

Usage

theme_minimal_white(
  base_size = 11,
  base_family = "",
  base_line_size = base_size/22,
  base_rect_size = base_size/22,
  base_col = "#323232",
  axis_text_family = base_family,
  axis_text_size = base_size,
  axis_title_family = base_family,
  axis_title_size = base_size,
  axis_title_face = "plain",
  axis_title_just = "mc",
  axis_col = base_col,
  grid = TRUE,
  axis = FALSE,
  ticks = FALSE,
  border = FALSE
)

Arguments

base_size

Numeric. Base font size (default: 11).

base_family

Character. Base font family (default: "").

base_line_size

Numeric. Base line size relative to 'base_size' (default: 'base_size / 22').

base_rect_size

Numeric. Base rectangle size relative to 'base_size' (default: 'base_size / 22').

base_col

Character. Base text color (default: '"#323232"').

axis_text_family

Character. Font family for axis text (default: 'base_family').

axis_text_size

Numeric. Font size for axis text (default: 'base_size').

axis_title_family

Character. Font family for axis titles (default: 'base_family').

axis_title_size

Numeric. Font size for axis titles (default: 'base_size').

axis_title_face

Character. Font face for axis titles (default: '"plain"').

axis_title_just

Character. Axis title justification. One of '[blmcrt]' (default: '"mc"').

axis_col

Character. Color for axis lines and text (default: 'base_col').

grid

Logical or Character. Controls the visibility of grid lines:

  • TRUE (default): Shows major and minor grid lines.

  • FALSE: Hides all grid lines.

  • Character string: Allows selective control using "X", "Y", "x", "y":

    • "X": Shows major grid lines on the x-axis.

    • "Y": Shows major grid lines on the y-axis.

    • "x": Shows minor grid lines on the x-axis.

    • "y": Shows minor grid lines on the y-axis.

axis

Logical or Character. Controls axis lines:

  • TRUE: Shows both x and y axis lines.

  • FALSE (default): Hides all axis lines.

  • Character string: Selectively controls axis lines:

    • "x": Shows only the x-axis line.

    • "y": Shows only the y-axis line.

    • "xy": Shows both axis lines.

ticks

Logical. Whether to show axis ticks (default: 'FALSE').

border

Logical. Whether to add a panel border around the plot (default: 'FALSE'). If TRUE, it overrides the 'axis' argument and hides axis lines.

Value

A ggplot2 theme object with a white plot background and customizable grid, axis, tick, and border settings.

Examples

library(ggplot2)
base_plot <- ggplot(mtcars,
                    aes(x = mpg,
                        y = wt)) +
  geom_point()

base_plot

base_plot +
  theme_minimal_white()

base_plot +
  theme_minimal_white(grid = "XY")

base_plot +
  theme_minimal_white(axis = "X")

base_plot +
  theme_minimal_white(border = TRUE)

base_plot +
  theme_minimal_white(grid = FALSE,
                      border = TRUE,
                      ticks = TRUE)


emilelatour/laviz documentation built on June 13, 2025, 9:41 a.m.