R/theme-oat.R

Defines functions theme_oat

Documented in theme_oat

#' Oat theme
#'
#' @description A complete theme for a oat panel background on a white plot
#'   background. The panel background fill defaults so `flexoki::flexoki$base["base50"]`.
#'   The default panel grid colour is derived automatically by blending the
#'   `panel_background_fill` with itself using `blends::multiply()` to
#'   produce a darker tone that stays harmonious with the panel background.
#'
#' @inheritParams theme_light
#'
#' @return A ggplot theme.
#' @export
#' @inherit theme_light examples
#'
theme_oat <- function(
    ...,
    text_size = 10,
    text_family = "",
    text_colour = flexoki::flexoki$base["black"],
    legend_place = "right",
    legend_axis_line_colour = plot_background_fill,
    legend_axis_line_linewidth = axis_line_linewidth,
    legend_background_fill = plot_background_fill,
    legend_key_fill = plot_background_fill,
    legend_ticks_colour = legend_axis_line_colour,
    legend_ticks_linewidth = legend_axis_line_linewidth,
    legend_ticks_length = grid::unit(c(2.75, 0), "pt"),
    axis_line_colour = flexoki::flexoki$base["base600"],
    axis_line_linewidth = 0.25,
    axis_ticks_colour = axis_line_colour,
    axis_ticks_linewidth = axis_line_linewidth,
    axis_ticks_length = grid::unit(3.66, "pt"),
    panel_background_fill = flexoki::flexoki$base["base50"],
    panel_grid_colour = blends::multiply(panel_background_fill),
    panel_grid_linetype = 1,
    panel_grid_linewidth = 1,
    panel_grid_minor_linetype = 1,
    panel_grid_minor_linewidth = 0.5,
    plot_background_fill = "white",
    panel_widths = NULL,
    panel_heights = NULL
) {
  theme_light(
    ...,
    text_size = text_size,
    text_family = text_family,
    text_colour = as.character(text_colour),
    legend_place = legend_place,
    legend_axis_line_colour = as.character(legend_axis_line_colour),
    legend_axis_line_linewidth = legend_axis_line_linewidth,
    legend_background_fill = as.character(legend_background_fill),
    legend_key_fill = as.character(legend_key_fill),
    legend_ticks_colour = as.character(legend_ticks_colour),
    legend_ticks_linewidth = legend_ticks_linewidth,
    legend_ticks_length = legend_ticks_length,
    axis_line_colour = as.character(axis_line_colour),
    axis_line_linewidth = axis_line_linewidth,
    axis_ticks_colour = as.character(axis_ticks_colour),
    axis_ticks_linewidth = axis_ticks_linewidth,
    axis_ticks_length = axis_ticks_length,
    plot_background_fill = as.character(plot_background_fill),
    panel_background_fill = as.character(panel_background_fill),
    panel_grid_colour = as.character(panel_grid_colour),
    panel_grid_linetype = panel_grid_linetype,
    panel_grid_linewidth = panel_grid_linewidth,
    panel_grid_minor_linetype = panel_grid_minor_linetype,
    panel_grid_minor_linewidth = panel_grid_minor_linewidth,
    panel_widths = panel_widths,
    panel_heights = panel_heights
  )
}

Try the ggrefine package in your browser

Any scripts or data that you put into this service are public.

ggrefine documentation built on May 4, 2026, 5:06 p.m.