Package 'ggrefine'

Title: Publication-Quality 'ggplot2' Themes
Description: Complete themes and functions for publication-quality 'ggplot2' visualisation.
Authors: David Hodge [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-3868-7501>)
Maintainer: David Hodge <[email protected]>
License: MIT + file LICENSE
Version: 0.5.0.9000
Built: 2026-10-13 12:22:53 UTC
Source: https://github.com/davidhodge931/ggrefine

Help Index


Blend fill into a derived colour mapping

Description

Note: this sets colour, not fill — fill is the value it reads from, colour is what it derives. Maps colour to a blended version of fill, evaluated after scale training via ggplot2::after_scale(). Attaches no scale itself — use scale_colour_blend_discrete() (or ⁠_continuous⁠/⁠_binned⁠) for a ready-to-plot version that also scales fill. Requires the ggrefine function to be used instead of ggplot2::ggplot to work where no fill aesthetic is mapped.

Usage

aes_colour_blend(blend = NULL)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

Value

A ggplot2 mapping object (as returned by ggplot2::aes()).


Derive a legible colour by contrasting against fill

Description

Note: this sets colour, not fill — fill is the value it reads from, colour is what it derives. Maps colour to a dark or light shade chosen for contrast against the layer's fill aesthetic, evaluated after scale training via ggplot2::after_scale(). Attaches no scale itself — sits downstream of whatever fill scale you've already applied.

Usage

aes_colour_contrast(dark = NULL, light = NULL, ...)

Arguments

dark

A dark colour string or hex value. If NULL, derived from the active theme.

light

A light colour string or hex value. If NULL, derived from the active theme.

...

Unused. Included to support trailing commas.

Value

A ggplot2 mapping object (as returned by ggplot2::aes()).


Derive a legible colour by contrasting against the panel background

Description

Maps colour to a dark or light shade chosen for contrast against the active theme's panel (or plot) background fill, evaluated after scale training via ggplot2::after_scale(). Attaches no scale itself.

Usage

aes_colour_panel(dark = NULL, light = NULL, ...)

Arguments

dark

A dark colour string or hex value. If NULL, derived from the active theme.

light

A light colour string or hex value. If NULL, derived from the active theme.

...

Unused. Included to support trailing commas.

Value

A ggplot2 mapping object (as returned by ggplot2::aes()).


Blend colour into a derived fill mapping

Description

Note: this sets fill, not colour — colour is the value it reads from, fill is what it derives. Maps fill to a blended version of colour, evaluated after scale training via ggplot2::after_scale(). Attaches no scale itself — use scale_fill_blend_discrete() (or ⁠_continuous⁠/⁠_binned⁠) for a ready-to-plot version that also scales colour.

Usage

aes_fill_blend(blend = NULL)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

Value

A ggplot2 mapping object (as returned by ggplot2::aes()).


Initialize a plot object with theme-aware default aesthetics

Description

ggrefine() initializes a plot object using a specified plotting function (defaults to ggplot2::ggplot()) and pre-populates default identity fill and colour aesthetic mappings derived from the active theme's geom defaults (falling back to "grey35" and "black" respectively).

These default aesthetics act as lightweight fallbacks and are cleanly overridden when explicit mappings are added in subsequent layers via ggplot2::aes().

Usage

ggrefine(data = NULL, initialise = ggplot2::ggplot)

Arguments

data

Default data frame or graph object to use for plot. If not specified, must be supplied in individual layers.

initialise

Function or lambda used to initialize the plot object (e.g., ggplot2::ggplot, ⁠\(x) ggplot2::ggplot(x)⁠, or ⁠\(x) ggraph::ggraph(x, layout = "kk")⁠). Defaults to ggplot2::ggplot().

Value

A plot object initialized with default aesthetic mappings.

Examples

library(ggplot2)
library(dplyr)

set_theme(ggrefine::theme_lights())

mpg |>
  count(class) |>
  ggrefine() +
  aes(x = class, y = n, fill = class) +
  geom_col() +
  scale_colour_blend_discrete()

Refine plot axes and panel grid

Description

A single entry point over the axis_mode x grid_mode combinations previously exposed as sixteen separate ⁠refine_*_*()⁠ functions. Those functions still exist internally (e.g. .refine_modern_drift()) and do the actual work; this function just dispatches to the right one.

Usage

refine_axis_grid(
  discrete,
  orientation = NULL,
  axis_mode = "modern",
  grid_mode = "drift"
)

Arguments

discrete

Character. Which axes should be treated as discrete for refinement purposes: "none", "x", "y", or "both". Required.

orientation

Character. The primary axis of interest: "x" or "y". Affects grid_mode values "drift" and "flow". If NULL (default), it is inferred from discrete: "y" gives "y", otherwise "x".

axis_mode

Character. One of "classic", "modern", "minimal", "void". Default "modern".

grid_mode

Character. One of "keep", "drift", "flow", "drop". Default "drift".

Details

axis_mode controls what happens to axis lines, ticks, text, and titles:

classic

Removes ticks on discrete axes only.

modern

Like classic, plus removes the axis line and ticks on the non-orientation axis.

minimal

Removes all axis lines and ticks, regardless of orientation or discreteness.

void

Like minimal, plus removes all axis text and titles.

grid_mode controls what happens to panel gridlines:

keep

Leaves panel gridlines unchanged.

drift

Removes gridlines on the orientation axis, but only when at least one axis is discrete.

flow

Removes gridlines on the orientation axis unconditionally.

drop

Removes all panel gridlines.

Value

A ggplot2 theme object.


Move Legend

Description

Helper shortcut to set legend position, location, and margins.

Usage

refine_legend(position = "right")

Arguments

position

Character. Where to place the legend ("right", "top", or "bottom").

Value

A ggplot2 theme object.


Scale fill, and derive colour by blending (binned)

Description

Scales fill with a binned colour scale, and additionally maps colour to a blended version of the resulting fill, via aes_colour_blend(). The colour legend is suppressed since fill already communicates the mapping.

Usage

scale_colour_blend_binned(blend = NULL, ...)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

...

Additional arguments passed on to ggplot2::scale_colour_binned(), and ggplot2::scale_fill_binned().

Value

A list of ggplot2 components (a mapping, a binned colour/fill scale, and a guide) that can be added to a ggplot object.


Scale fill, and derive colour by blending (continuous)

Description

Scales fill with a continuous colour scale, and additionally maps colour to a blended version of the resulting fill, via aes_colour_blend(). The colour legend is suppressed since fill already communicates the mapping.

Usage

scale_colour_blend_continuous(blend = NULL, ...)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

...

Additional arguments passed on to ggplot2::scale_colour_continuous(), and ggplot2::scale_fill_continuous().

Value

A list of ggplot2 components (a mapping, a continuous colour/fill scale, and a guide) that can be added to a ggplot object.


Scale fill, and derive colour by blending (discrete)

Description

Scales fill with a discrete colour scale, and additionally maps colour to a blended version of the resulting fill, via aes_colour_blend(). The colour legend is suppressed since fill already communicates the mapping.

Usage

scale_colour_blend_discrete(blend = NULL, ...)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

...

Additional arguments passed on to ggplot2::scale_colour_discrete(), and ggplot2::scale_fill_discrete().

Value

A list of ggplot2 components (a mapping, a discrete colour/fill scale, and a guide) that can be added to a ggplot object.


Scale colour, and derive fill by blending (binned)

Description

Scales colour with a binned colour scale, and additionally maps fill to a blended version of the resulting colour, via aes_fill_blend(). The fill legend is suppressed since colour already communicates the mapping.

Usage

scale_fill_blend_binned(blend = NULL, ...)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

...

Additional arguments passed on to ggplot2::scale_colour_binned(), and ggplot2::scale_fill_binned().

Value

A list of ggplot2 components (a mapping, a binned colour/fill scale, and a guide) that can be added to a ggplot object.


Scale colour, and derive fill by blending (continuous)

Description

Scales colour with a continuous colour scale, and additionally maps fill to a blended version of the resulting colour, via aes_fill_blend(). The fill legend is suppressed since colour already communicates the mapping.

Usage

scale_fill_blend_continuous(blend = NULL, ...)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

...

Additional arguments passed on to ggplot2::scale_colour_continuous(), and ggplot2::scale_fill_continuous().

Value

A list of ggplot2 components (a mapping, a continuous colour/fill scale, and a guide) that can be added to a ggplot object.


Scale colour, and derive fill by blending (discrete)

Description

Scales colour with a discrete colour scale, and additionally maps fill to a blended version of the resulting colour, via aes_fill_blend(). The fill legend is suppressed since colour already communicates the mapping.

Usage

scale_fill_blend_discrete(blend = NULL, ...)

Arguments

blend

A function that takes a colour vector and returns a blended colour vector.

...

Additional arguments passed on to ggplot2::scale_colour_discrete(), and ggplot2::scale_fill_discrete().

Value

A list of ggplot2 components (a mapping, a discrete colour/fill scale, and a guide) that can be added to a ggplot object.


Set continuous x-axis minimum flush to zero

Description

A convenience wrapper around ggplot2::scale_x_continuous() that sets the lower limit of the x-axis strictly to zero with no padding by default, while allowing full customization of scale parameters.

Usage

scale_x_zero(expand = ggplot2::expansion(c(0, 0.05)), limits = c(0, NA), ...)

Arguments

expand

Padding multiplier/addend vector. Defaults to expansion(c(0, 0.05)).

limits

Axis limits. Defaults to c(0, NA) to force the lower bound to zero.

...

Additional arguments passed on to ggplot2::scale_x_continuous().

Value

A ScaleContinuousPosition object.


Set continuous y-axis minimum flush to zero

Description

A convenience wrapper around ggplot2::scale_y_continuous() that sets the lower limit of the y-axis strictly to zero with no padding by default, while allowing full customization of scale parameters.

Usage

scale_y_zero(expand = ggplot2::expansion(c(0, 0.05)), limits = c(0, NA), ...)

Arguments

expand

Padding multiplier/addend vector. Defaults to expansion(c(0, 0.05)).

limits

Axis limits. Defaults to c(0, NA) to force the lower bound to zero.

...

Additional arguments passed on to ggplot2::scale_y_continuous().

Value

A ScaleContinuousPosition object.


theme_darks——————————————————————

Description

A complete theme with a dark plot and panel background. Uses flexoki inspired colours.

Usage

theme_darks(
  ...,
  text_size = 10,
  text_family = "",
  text_colour = "#CECDC3",
  title_size = NULL,
  title_family = NULL,
  title_colour = NULL,
  subtitle_size = NULL,
  subtitle_family = NULL,
  subtitle_colour = NULL,
  caption_size = NULL,
  caption_family = NULL,
  caption_colour = NULL,
  caption_hjust = 0,
  legend_position = "right",
  legend_axis_line_colour = NULL,
  legend_axis_line_linewidth = NULL,
  legend_background_fill = NULL,
  legend_key_fill = NULL,
  legend_ticks_colour = NULL,
  legend_ticks_linewidth = NULL,
  legend_ticks_linetype = 1,
  legend_ticks_length = grid::unit(c(2.75, 0), "pt"),
  axis_line_colour = NULL,
  axis_line_linewidth = 0.15,
  axis_ticks_colour = NULL,
  axis_ticks_linewidth = NULL,
  axis_ticks_length = grid::unit(3.66, "pt"),
  panel_background_fill = "#282726",
  panel_grid_colour = "#100F0F",
  panel_grid_linetype = 1,
  panel_grid_linewidth = 1,
  panel_grid_minor_linetype = 1,
  panel_grid_minor_linewidth = 0.5,
  plot_background_fill = "#100F0F"
)

Arguments

...

Require named arguments (and support trailing commas).

text_size

The base size of the text theme element. Defaults to 10.

text_family

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

text_colour

The base colour of the text theme element.

title_size

The size of the plot.title theme element. Defaults to text_size.

title_family

The family of the plot.title theme element. Defaults to text_family.

title_colour

The colour of the plot.title theme element. Defaults to text_colour.

subtitle_size

The size of the plot.subtitle theme element. Defaults to text_size.

subtitle_family

The family of the plot.subtitle theme element. Defaults to text_family.

subtitle_colour

The colour of the plot.subtitle theme element. Defaults to text_colour.

caption_size

The size of the plot.caption theme element. Defaults to text_size.

caption_family

The family of the plot.caption theme element. Defaults to text_family.

caption_colour

The colour of the plot.caption theme element. Defaults to text_colour.

caption_hjust

The horizontal justification of the plot.caption theme element. Defaults to 0.

legend_position

The position of the legend. Either "right", "top" or "bottom".

legend_axis_line_colour

The colour of the legend.axis.line theme element.

legend_axis_line_linewidth

The linewidth of the legend.axis.line theme element.

legend_background_fill

The fill (and colour) of the legend.background theme element.

legend_key_fill

The fill (and colour) of the legend.key theme element.

legend_ticks_colour

The colour of the legend.ticks theme element.

legend_ticks_linewidth

The linewidth of the legend.ticks theme element.

legend_ticks_linetype

The linetype of the legend.ticks theme element. Defaults to 1.

legend_ticks_length

The length of the legend.ticks.length theme element.

axis_line_colour

The colour of the axis.line theme element. Defaults to text_colour.

axis_line_linewidth

The linewidth of the axis.line theme element.

axis_ticks_colour

The colour of the axis.ticks theme element.

axis_ticks_linewidth

The linewidth of the axis.ticks theme element.

axis_ticks_length

The length of the axis.ticks.length theme element.

panel_background_fill

The fill (and colour) of the panel.background theme element.

panel_grid_colour

The colour of the panel.grid theme element.

panel_grid_linetype

The linetype of the panel.grid.major theme element.

panel_grid_linewidth

The linewidth of the panel.grid.major theme element.

panel_grid_minor_linetype

The linetype of the panel.grid.minor theme element.

panel_grid_minor_linewidth

The linewidth of the panel.grid.minor theme element.

plot_background_fill

The fill (and colour) of the plot.background theme element.

Details

Dark theme

Value

A ggplot theme.


theme_greys——————————————————————

Description

A complete theme with a light grey panel background and white panel grid colour. Uses flexoki inspired colours.

Usage

theme_greys(
  ...,
  text_size = 10,
  text_family = "",
  text_colour = "#100F0F",
  title_size = NULL,
  title_family = NULL,
  title_colour = NULL,
  subtitle_size = NULL,
  subtitle_family = NULL,
  subtitle_colour = NULL,
  caption_size = NULL,
  caption_family = NULL,
  caption_colour = NULL,
  caption_hjust = 0,
  legend_position = "right",
  legend_axis_line_colour = NULL,
  legend_axis_line_linewidth = NULL,
  legend_background_fill = NULL,
  legend_key_fill = NULL,
  legend_ticks_colour = NULL,
  legend_ticks_linewidth = NULL,
  legend_ticks_linetype = 1,
  legend_ticks_length = grid::unit(c(2.75, 0), "pt"),
  axis_line_colour = NULL,
  axis_line_linewidth = 0.15,
  axis_ticks_colour = NULL,
  axis_ticks_linewidth = NULL,
  axis_ticks_length = grid::unit(3.66, "pt"),
  panel_background_fill = "#F2F0E5FF",
  panel_grid_colour = "white",
  panel_grid_linetype = 1,
  panel_grid_linewidth = 1,
  panel_grid_minor_linetype = 1,
  panel_grid_minor_linewidth = 0.5,
  plot_background_fill = "white"
)

Arguments

...

Require named arguments (and support trailing commas).

text_size

The base size of the text theme element. Defaults to 10.

text_family

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

text_colour

The base colour of the text theme element.

title_size

The size of the plot.title theme element. Defaults to text_size.

title_family

The family of the plot.title theme element. Defaults to text_family.

title_colour

The colour of the plot.title theme element. Defaults to text_colour.

subtitle_size

The size of the plot.subtitle theme element. Defaults to text_size.

subtitle_family

The family of the plot.subtitle theme element. Defaults to text_family.

subtitle_colour

The colour of the plot.subtitle theme element. Defaults to text_colour.

caption_size

The size of the plot.caption theme element. Defaults to text_size.

caption_family

The family of the plot.caption theme element. Defaults to text_family.

caption_colour

The colour of the plot.caption theme element. Defaults to text_colour.

caption_hjust

The horizontal justification of the plot.caption theme element. Defaults to 0.

legend_position

The position of the legend. Either "right", "top" or "bottom".

legend_axis_line_colour

The colour of the legend.axis.line theme element.

legend_axis_line_linewidth

The linewidth of the legend.axis.line theme element.

legend_background_fill

The fill (and colour) of the legend.background theme element.

legend_key_fill

The fill (and colour) of the legend.key theme element.

legend_ticks_colour

The colour of the legend.ticks theme element.

legend_ticks_linewidth

The linewidth of the legend.ticks theme element.

legend_ticks_linetype

The linetype of the legend.ticks theme element. Defaults to 1.

legend_ticks_length

The length of the legend.ticks.length theme element.

axis_line_colour

The colour of the axis.line theme element. Defaults to text_colour.

axis_line_linewidth

The linewidth of the axis.line theme element.

axis_ticks_colour

The colour of the axis.ticks theme element.

axis_ticks_linewidth

The linewidth of the axis.ticks theme element.

axis_ticks_length

The length of the axis.ticks.length theme element.

panel_background_fill

The fill (and colour) of the panel.background theme element.

panel_grid_colour

The colour of the panel.grid theme element.

panel_grid_linetype

The linetype of the panel.grid.major theme element.

panel_grid_linewidth

The linewidth of the panel.grid.major theme element.

panel_grid_minor_linetype

The linetype of the panel.grid.minor theme element.

panel_grid_minor_linewidth

The linewidth of the panel.grid.minor theme element.

plot_background_fill

The fill (and colour) of the plot.background theme element.

Details

Grey theme

Value

A ggplot theme.


theme_lights——————————————————————

Description

A complete theme with a white panel background and a light panel grid colour. Uses flexoki inspired colours.

Usage

theme_lights(
  ...,
  text_size = 10,
  text_family = "",
  text_colour = "#100F0F",
  title_size = NULL,
  title_family = NULL,
  title_colour = NULL,
  subtitle_size = NULL,
  subtitle_family = NULL,
  subtitle_colour = NULL,
  caption_size = NULL,
  caption_family = NULL,
  caption_colour = NULL,
  caption_hjust = 0,
  legend_position = "right",
  legend_axis_line_colour = NULL,
  legend_axis_line_linewidth = NULL,
  legend_background_fill = NULL,
  legend_key_fill = NULL,
  legend_ticks_colour = NULL,
  legend_ticks_linewidth = NULL,
  legend_ticks_linetype = 1,
  legend_ticks_length = grid::unit(c(2.75, 0), "pt"),
  axis_line_colour = NULL,
  axis_line_linewidth = 0.15,
  axis_ticks_colour = NULL,
  axis_ticks_linewidth = NULL,
  axis_ticks_length = grid::unit(3.66, "pt"),
  panel_background_fill = "white",
  panel_grid_colour = "#F2F0E5",
  panel_grid_linetype = 1,
  panel_grid_linewidth = 1,
  panel_grid_minor_linetype = 1,
  panel_grid_minor_linewidth = 0.5,
  plot_background_fill = "white"
)

Arguments

...

Require named arguments (and support trailing commas).

text_size

The base size of the text theme element. Defaults to 10.

text_family

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

text_colour

The base colour of the text theme element.

title_size

The size of the plot.title theme element. Defaults to text_size.

title_family

The family of the plot.title theme element. Defaults to text_family.

title_colour

The colour of the plot.title theme element. Defaults to text_colour.

subtitle_size

The size of the plot.subtitle theme element. Defaults to text_size.

subtitle_family

The family of the plot.subtitle theme element. Defaults to text_family.

subtitle_colour

The colour of the plot.subtitle theme element. Defaults to text_colour.

caption_size

The size of the plot.caption theme element. Defaults to text_size.

caption_family

The family of the plot.caption theme element. Defaults to text_family.

caption_colour

The colour of the plot.caption theme element. Defaults to text_colour.

caption_hjust

The horizontal justification of the plot.caption theme element. Defaults to 0.

legend_position

The position of the legend. Either "right", "top" or "bottom".

legend_axis_line_colour

The colour of the legend.axis.line theme element.

legend_axis_line_linewidth

The linewidth of the legend.axis.line theme element.

legend_background_fill

The fill (and colour) of the legend.background theme element.

legend_key_fill

The fill (and colour) of the legend.key theme element.

legend_ticks_colour

The colour of the legend.ticks theme element.

legend_ticks_linewidth

The linewidth of the legend.ticks theme element.

legend_ticks_linetype

The linetype of the legend.ticks theme element. Defaults to 1.

legend_ticks_length

The length of the legend.ticks.length theme element.

axis_line_colour

The colour of the axis.line theme element. Defaults to text_colour.

axis_line_linewidth

The linewidth of the axis.line theme element.

axis_ticks_colour

The colour of the axis.ticks theme element.

axis_ticks_linewidth

The linewidth of the axis.ticks theme element.

axis_ticks_length

The length of the axis.ticks.length theme element.

panel_background_fill

The fill (and colour) of the panel.background theme element.

panel_grid_colour

The colour of the panel.grid theme element.

panel_grid_linetype

The linetype of the panel.grid.major theme element.

panel_grid_linewidth

The linewidth of the panel.grid.major theme element.

panel_grid_minor_linetype

The linetype of the panel.grid.minor theme element.

panel_grid_minor_linewidth

The linewidth of the panel.grid.minor theme element.

plot_background_fill

The fill (and colour) of the plot.background theme element.

Details

Lights theme

Value

A ggplot theme.


update_darks

Description

Updates the currently active/set theme in place with the colours of theme_darks(), via ggplot2::theme_update(). Useful for recolouring every plot for the rest of the session without swapping out the full theme.

Usage

update_darks(
  ...,
  text_colour = "#CECDC3",
  title_colour = NULL,
  subtitle_colour = NULL,
  caption_colour = NULL,
  axis_line_colour = NULL,
  axis_ticks_colour = NULL,
  legend_axis_line_colour = NULL,
  legend_background_fill = NULL,
  legend_key_fill = NULL,
  legend_ticks_colour = NULL,
  panel_background_fill = "#282726",
  panel_grid_colour = "#100F0F",
  plot_background_fill = "#100F0F"
)

Arguments

...

Require named arguments (and support trailing commas).

text_colour

The base colour of the text theme element.

title_colour

The colour of the plot.title theme element. Defaults to text_colour.

subtitle_colour

The colour of the plot.subtitle theme element. Defaults to text_colour.

caption_colour

The colour of the plot.caption theme element. Defaults to text_colour.

axis_line_colour

The colour of the axis.line theme element. Defaults to text_colour.

axis_ticks_colour

The colour of the axis.ticks theme element. Defaults to axis_line_colour.

legend_axis_line_colour

The colour of the legend.axis.line theme element. Defaults to plot_background_fill.

legend_background_fill

The fill (and colour) of the legend.background theme element. Defaults to plot_background_fill.

legend_key_fill

The fill (and colour) of the legend.key theme element. Defaults to plot_background_fill.

legend_ticks_colour

The colour of the legend.ticks theme element. Defaults to legend_axis_line_colour.

panel_background_fill

The fill (and colour) of the panel.background theme element.

panel_grid_colour

The colour of the panel.grid theme element.

plot_background_fill

The fill (and colour) of the plot.background theme element.

Details

Update the set theme (Darks)

Value

The previous theme, invisibly (see ggplot2::theme_update()).


update_greys

Description

Updates the currently active/set theme in place with the colours of theme_greys(), via ggplot2::theme_update(). Useful for recolouring every plot for the rest of the session without swapping out the full theme.

Usage

update_greys(
  ...,
  text_colour = "#100F0F",
  title_colour = NULL,
  subtitle_colour = NULL,
  caption_colour = NULL,
  axis_line_colour = NULL,
  axis_ticks_colour = NULL,
  legend_axis_line_colour = NULL,
  legend_background_fill = NULL,
  legend_key_fill = NULL,
  legend_ticks_colour = NULL,
  panel_background_fill = "#F2F0E5FF",
  panel_grid_colour = "white",
  plot_background_fill = "white"
)

Arguments

...

Require named arguments (and support trailing commas).

text_colour

The base colour of the text theme element.

title_colour

The colour of the plot.title theme element. Defaults to text_colour.

subtitle_colour

The colour of the plot.subtitle theme element. Defaults to text_colour.

caption_colour

The colour of the plot.caption theme element. Defaults to text_colour.

axis_line_colour

The colour of the axis.line theme element. Defaults to text_colour.

axis_ticks_colour

The colour of the axis.ticks theme element. Defaults to axis_line_colour.

legend_axis_line_colour

The colour of the legend.axis.line theme element. Defaults to plot_background_fill.

legend_background_fill

The fill (and colour) of the legend.background theme element. Defaults to plot_background_fill.

legend_key_fill

The fill (and colour) of the legend.key theme element. Defaults to plot_background_fill.

legend_ticks_colour

The colour of the legend.ticks theme element. Defaults to legend_axis_line_colour.

panel_background_fill

The fill (and colour) of the panel.background theme element.

panel_grid_colour

The colour of the panel.grid theme element.

plot_background_fill

The fill (and colour) of the plot.background theme element.

Details

Update the set theme (greys)

Value

The previous theme, invisibly (see ggplot2::theme_update()).


update_lights

Description

Updates the currently active/set theme in place with the colours of theme_lights(), via ggplot2::theme_update(). Useful for recolouring every plot for the rest of the session without swapping out the full theme.

Usage

update_lights(
  ...,
  text_colour = "#100F0F",
  title_colour = NULL,
  subtitle_colour = NULL,
  caption_colour = NULL,
  axis_line_colour = NULL,
  axis_ticks_colour = NULL,
  legend_axis_line_colour = NULL,
  legend_background_fill = NULL,
  legend_key_fill = NULL,
  legend_ticks_colour = NULL,
  panel_background_fill = "white",
  panel_grid_colour = "#F2F0E5",
  plot_background_fill = "white"
)

Arguments

...

Require named arguments (and support trailing commas).

text_colour

The base colour of the text theme element.

title_colour

The colour of the plot.title theme element. Defaults to text_colour.

subtitle_colour

The colour of the plot.subtitle theme element. Defaults to text_colour.

caption_colour

The colour of the plot.caption theme element. Defaults to text_colour.

axis_line_colour

The colour of the axis.line theme element. Defaults to text_colour.

axis_ticks_colour

The colour of the axis.ticks theme element. Defaults to axis_line_colour.

legend_axis_line_colour

The colour of the legend.axis.line theme element. Defaults to plot_background_fill.

legend_background_fill

The fill (and colour) of the legend.background theme element. Defaults to plot_background_fill.

legend_key_fill

The fill (and colour) of the legend.key theme element. Defaults to plot_background_fill.

legend_ticks_colour

The colour of the legend.ticks theme element. Defaults to legend_axis_line_colour.

panel_background_fill

The fill (and colour) of the panel.background theme element.

panel_grid_colour

The colour of the panel.grid theme element.

plot_background_fill

The fill (and colour) of the plot.background theme element.

Details

Update the set theme (Lights)

Value

The previous theme, invisibly (see ggplot2::theme_update()).


Update colour/fill palettes or fixed geom colour/fill

Description

Modifies active theme settings for fixed, discrete, and continuous palettes only for parameters explicitly provided by the user.

Usage

update_palette(fixed = NULL, discrete = NULL, continuous = NULL)

Arguments

fixed

Colour applied to geometric elements via element_geom(). Updates both colour and fill.

discrete

Palette specification (e.g., scales::pal_hue()) for discrete scales (palette.colour.discrete and palette.fill.discrete).

continuous

Palette specification for continuous scales (palette.colour.continuous and palette.fill.continuous).

Value

Invisibly returns the result of the theme_update() calls.

Examples

## Not run: 
# Update fixed geom colour
update_palette(fixed = "steelblue")

# Update discrete palette
update_palette(discrete = scales::pal_hue())

# Update continuous palette
update_palette(continuous = scales::pal_viridis())

## End(Not run)

Update panel dimensions in the current ggplot theme

Description

Modifies panel dimensions such as heights and widths by updating the global theme settings.

Usage

update_panel_size(heights = ggplot2::waiver(), widths = ggplot2::waiver())

Arguments

heights

A margin or unit object specifying the panel heights (e.g., grid::unit(5, "cm")).

widths

A margin or unit object specifying the panel widths (e.g., grid::unit(5, "cm")).

Value

Invisibly returns the updated theme object.

Examples

## Not run: 
update_panel_size(
  heights = grid::unit(6, "cm"),
  widths = grid::unit(8, "cm")
)

## End(Not run)