Package 'ggblanket'

Title: Simplify 'ggplot2' Visualisation
Description: Simplify 'ggplot2' visualisation with 'ggblanket' wrapper functions.
Authors: David Hodge [aut, cre, cph]
Maintainer: David Hodge <[email protected]>
License: MIT + file LICENSE
Version: 12.1.0
Built: 2025-01-27 13:00:00 UTC
Source: CRAN

Help Index


A colour aesthetic for contrast

Description

A colour aesthetic to contrast with a fill aesthetic. Can be spliced into ggplot2::aes with rlang::!!!.

Usage

aes_colour_contrast(..., dark = "#121B24FF", light = "#FFFFFFFF")

Arguments

...

Provided to require argument naming, support trailing commas etc.

dark

A dark colour.

light

A light colour.

Value

A ggplot2 aesthetic

Examples

library(ggplot2)
library(dplyr)
library(stringr)
library(palmerpenguins)

set_blanket()

penguins |>
  count(species, sex) |>
  gg_col(
    x = sex,
    y = n,
    col = species,
    label = n,
    position = position_dodge(preserve = "single"),
    width = 0.75,
    x_labels = \(x) str_to_sentence(x),
  ) +
  geom_text(
    mapping = aes_colour_contrast(),
    position = position_dodge(width = 0.75, preserve = "single"),
    vjust = 1.33,
    show.legend = FALSE,
  )

penguins |>
  count(species, sex) |>
  gg_col(
    x = sex,
    y = n,
    col = species,
    position = position_dodge(preserve = "single"),
    width = 0.75,
    x_labels = \(x) str_to_sentence(x),
    theme = dark_mode_r(),
  ) +
  geom_text(
    mapping = aes(label = n, !!!aes_colour_contrast(dark = darkness[3], light = darkness[1])),
    position = position_dodge(width = 0.75, preserve = "single"),
    vjust = 1.33,
    show.legend = FALSE,
  )

Replace a axis line with an annotated segment

Description

Replace a axis line with an annotated segment, so that geom features are in front of it.

Usage

annotate_axis_line(
  axis = "x",
  ...,
  x_position = "bottom",
  y_position = "left",
  colour = NULL,
  linewidth = NULL
)

Arguments

axis

The axis. Either "x" or "y"

...

Extra parameters passed to ggplot2::annotate("segment", ...).

x_position

The position of the "x" axis, if applicable. Either "bottom" or "top".

y_position

The position of the "y" axis, if applicable. Either "left" or "right".

colour

The colour of the annotated segment.

linewidth

The linewidth of the annotated segment.

Value

A list of a annotate layer and theme elements.

Examples

library(dplyr)
library(ggplot2)
library(ggblanket)
library(palmerpenguins)

set_blanket()

penguins |>
  add_row(
    flipper_length_mm = 175,
    body_mass_g = 2500,
    species = "Adelie",
  ) |>
  gg_blanket(
    x = flipper_length_mm,
    y = body_mass_g,
    col = species,
  ) +
  annotate_axis_line() +
  geom_point(size = 2.5)

A blue colour

Description

A blue colour.

Usage

blue

Value

A character vector.

Examples

scales::show_col(blue)

Dark mode theme family

Description

A dark mode family of functions:

  • dark_mode_r() with legend on right

  • dark_mode_t() with legend on top

  • dark_mode_b() with legend on bottom

Usage

dark_mode_r(
  ...,
  base_size = 11,
  base_family = "",
  base_colour = "#C8D7DFFF",
  axis_line_colour = "#C8D7DFFF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  panel_grid_colour = "#00040AFF",
  panel_grid_linewidth = 1.33,
  panel_background_fill = "#050D1BFF",
  plot_background_fill = "#00040AFF",
  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 = ggplot2::rel(c(0.175, 0))
)

dark_mode_t(
  ...,
  base_size = 11,
  base_family = "",
  base_colour = "#C8D7DFFF",
  axis_line_colour = "#C8D7DFFF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  panel_grid_colour = "#00040AFF",
  panel_grid_linewidth = 1.33,
  panel_background_fill = "#050D1BFF",
  plot_background_fill = "#00040AFF",
  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 = ggplot2::rel(c(0.175, 0))
)

dark_mode_b(
  ...,
  base_size = 11,
  base_family = "",
  base_colour = "#C8D7DFFF",
  axis_line_colour = "#C8D7DFFF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  panel_grid_colour = "#00040AFF",
  panel_grid_linewidth = 1.33,
  panel_background_fill = "#050D1BFF",
  plot_background_fill = "#00040AFF",
  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 = ggplot2::rel(c(0.175, 0))
)

Arguments

...

Provided to require argument naming, support trailing commas etc.

base_size

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

base_family

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

base_colour

The base colour of the text theme element.

axis_line_colour

The colour of the axis.line theme element.

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.

panel_grid_colour

The colour of the panel.grid theme element.

panel_grid_linewidth

The linewidth of the panel.grid theme element.

panel_background_fill

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

plot_background_fill

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

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_length

The legend.ticks.length theme element.

Value

A ggplot theme.

Examples

library(palmerpenguins)
library(ggplot2)

set_blanket()

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

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

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

Area ggplot

Description

Create an area ggplot with a wrapper around ggplot2::ggplot() + geom_area().

Usage

gg_area(
  data = NULL,
  ...,
  stat = "align",
  position = "stack",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

economics |>
  gg_area(
    x = date,
    y = unemploy,
    y_label = "Unemployment",
  )

Bar ggplot

Description

Create a bar ggplot with a wrapper around ggplot2::ggplot() + geom_bar().

Usage

gg_bar(
  data = NULL,
  ...,
  stat = "count",
  position = "stack",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_bar(
    y = species,
    width = 0.75,
  )

Bin_2d ggplot

Description

Create a bin2d ggplot with a wrapper around ggplot2::ggplot() + geom_bin_2d().

Usage

gg_bin_2d(
  data = NULL,
  ...,
  stat = "bin2d",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

diamonds |>
  gg_bin_2d(
    x = carat,
    y = price,
  )

Blanket ggplot

Description

Create a blanket ggplot with a wrapper around ggplot2::ggplot() + layer() with geom_blank() defaults. This function underlies all other ⁠gg_*⁠ functions. It contains a geom argument for maximum flexibility.

Usage

gg_blanket(
  data = NULL,
  ...,
  geom = "blank",
  stat = "identity",
  position = "identity",
  coord = NULL,
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

geom

A geometric object to display the data. A snakecase character string of a ggproto Geom subclass object minus the Geom prefix (e.g. "point").

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_blanket(
    geom = "violin",
    stat = "ydensity",
    position = "dodge",
    x = species,
    y = body_mass_g,
    col = sex,
  )

Boxplot ggplot

Description

Create a boxplot ggplot with a wrapper around ggplot2::ggplot() + geom_boxplot().

Usage

gg_boxplot(
  data = NULL,
  ...,
  stat = "boxplot",
  position = "dodge2",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_boxplot(
    x = flipper_length_mm,
    y = species,
    col = sex,
    blend = "multiply",
  )

Col ggplot

Description

Create a col ggplot with a wrapper around ggplot2::ggplot() + geom_col().

Usage

gg_col(
  data = NULL,
  ...,
  stat = "identity",
  position = "stack",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  tidyr::drop_na(sex) |>
  group_by(sex, species) |>
  summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |>
  gg_col(
    x = flipper_length_mm,
    y = species,
    col = sex,
    position = position_dodge(preserve = "single"),
    width = 0.75,
  )

Contour ggplot

Description

Create a contour ggplot with a wrapper around ggplot2::ggplot() + geom_contour().

Usage

gg_contour(
  data = NULL,
  ...,
  stat = "contour",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

ggplot2::faithfuld |>
  gg_contour(
    x = waiting,
    y = eruptions,
    z = density,
  )

Contour_filled ggplot

Description

Create a contour_filled ggplot with a wrapper around ggplot2::ggplot() + geom_contour_filled().

Usage

gg_contour_filled(
  data = NULL,
  ...,
  stat = "contour_filled",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

faithfuld |>
  gg_contour_filled(
    x = waiting,
    y = eruptions,
    z = density,
    bins = 8,
  )

Crossbar ggplot

Description

Create a crossbar ggplot with a wrapper around ggplot2::ggplot() + geom_crossbar().

Usage

gg_crossbar(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, 3, 4),
  group = factor(c(1, 2, 1, 2)),
  upper = c(1.1, 5.3, 3.3, 4.2),
  lower = c(0.8, 4.6, 2.4, 3.6)
) |>
  gg_crossbar(
    x = trt,
    y = resp,
    ymin = lower,
    ymax = upper,
    col = group,
    width = 0.5,
    x_label = "Treatment",
    y_label = "Response",
    blend = "multiply",
  )

Density ggplot

Description

Create a density ggplot with a wrapper around ggplot2::ggplot() + geom_density().

Usage

gg_density(
  data = NULL,
  ...,
  stat = "density",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_density(
    x = flipper_length_mm,
    col = species,
    blend = "multiply",
  )

Density_2d ggplot

Description

Create a density_2d ggplot with a wrapper around ggplot2::ggplot() + geom_density_2d().

Usage

gg_density_2d(
  data = NULL,
  ...,
  stat = "density_2d",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

faithful |>
  gg_density_2d(
    x = waiting,
    y = eruptions,
    bins = 8,
    contour = TRUE,
  )

Density_2d_filled ggplot

Description

Create a density_2d_filled ggplot with a wrapper around ggplot2::ggplot() + geom_density_2d_filled().

Usage

gg_density_2d_filled(
  data = NULL,
  ...,
  stat = "density_2d_filled",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

faithful |>
  gg_density_2d_filled(
    x = waiting,
    y = eruptions,
    bins = 8,
    contour = TRUE,
  )

Errorbar ggplot

Description

Create a errorbar ggplot with a wrapper around ggplot2::ggplot() + geom_errorbar().

Usage

gg_errorbar(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, 3, 4),
  group = factor(c(1, 2, 1, 2)),
  upper = c(1.1, 5.3, 3.3, 4.2),
  lower = c(0.8, 4.6, 2.4, 3.6)
) |>
  gg_errorbar(
    x = trt,
    ymin = lower,
    ymax = upper,
    col = group,
    width = 0.1,
    x_label = "Treatment",
    y_label = "Response",
  )

Freqpoly ggplot

Description

Create a freqpoly ggplot with a wrapper around ggplot2::ggplot() + geom_freqpoly().

Usage

gg_freqpoly(
  data = NULL,
  ...,
  stat = "bin",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_freqpoly(
    x = flipper_length_mm,
    col = sex,
  )

Function ggplot

Description

Create a function ggplot with a wrapper around ggplot2::ggplot() + geom_function().

Usage

gg_function(
  data = NULL,
  ...,
  stat = "function",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

gg_function(
  fun = \(x) dnorm(x, mean = 0, sd = 5),
  x_expand_limits = qnorm(p = c(0.005, 0.995), mean = 0, sd = 5),
  y_expand_limits = 0,
)

Hex ggplot

Description

Create a hex ggplot with a wrapper around ggplot2::ggplot() + geom_hex().

Usage

gg_hex(
  data = NULL,
  ...,
  stat = "binhex",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

diamonds |>
  gg_hex(
    x = carat,
    y = price,
  )

Histogram ggplot

Description

Create a histogram ggplot with a wrapper around ggplot2::ggplot() + geom_histogram().

Usage

gg_histogram(
  data = NULL,
  ...,
  stat = "bin",
  position = "stack",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_histogram(
    x = flipper_length_mm,
    col = sex,
    bins = 50,
  )

Jitter ggplot

Description

Create a jitter ggplot with a wrapper around ggplot2::ggplot() + geom_jitter().

Usage

gg_jitter(
  data = NULL,
  ...,
  stat = "identity",
  position = "jitter",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

set.seed(123)

penguins |>
  gg_jitter(
    x = species,
    y = body_mass_g,
    col = flipper_length_mm,
    position = position_jitter(height = 0),
    y_expand_limits = 0,
    col_steps = TRUE,
  )

Label ggplot

Description

Create a label ggplot with a wrapper around ggplot2::ggplot() + geom_label().

Usage

gg_label(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()
set_font_defaults()

bind_rows(
  mtcars |> slice_min(order_by = mpg),
  mtcars |> slice_max(order_by = mpg)
) |>
  tibble::rownames_to_column("themel") |>
  gg_label(
    x = themel,
    y = mpg,
    label = themel,
    y_expand_limits = 0,
    y_label = "Miles per gallon",
    col_palette = c(orange, "white", teal),
  )

Line ggplot

Description

Create a line ggplot with a wrapper around ggplot2::ggplot() + geom_line().

Usage

gg_line(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

economics |>
  gg_line(
    x = date,
    y = unemploy,
    y_expand_limits = 0,
    y_label = "Unemployment",
  )

Linerange ggplot

Description

Create a linerange ggplot with a wrapper around ggplot2::ggplot() + geom_linerange().

Usage

gg_linerange(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, 3, 4),
  group = factor(c(1, 2, 1, 2)),
  upper = c(1.1, 5.3, 3.3, 4.2),
  lower = c(0.8, 4.6, 2.4, 3.6)
) |>
  gg_linerange(
    x = trt,
    ymin = lower,
    ymax = upper,
    col = group,
    position = position_dodge(width = 0.2),
    x_label = "Treatment",
    y_label = "Response",
  )

Path ggplot

Description

Create a path ggplot with a wrapper around ggplot2::ggplot() + geom_path().

Usage

gg_path(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

economics |>
  mutate(unemploy_rate = unemploy / pop) |>
  gg_path(
    x = unemploy_rate,
    y = psavert,
    x_label = "Unemployment rate",
    y_expand_limits = 0,
    y_label = "Personal savings rate",
  )

Point ggplot

Description

Create a point ggplot with a wrapper around ggplot2::ggplot() + geom_point().

Usage

gg_point(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

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

Pointrange ggplot

Description

Create a pointrange ggplot with a wrapper around ggplot2::ggplot() + geom_pointrange().

Usage

gg_pointrange(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, 3, 4),
  group = factor(c(1, 2, 1, 2)),
  upper = c(1.1, 5.3, 3.3, 4.2),
  lower = c(0.8, 4.6, 2.4, 3.6)
) |>
  gg_pointrange(
    x = trt,
    y = resp,
    col = group,
    ymin = lower,
    ymax = upper,
    position = position_dodge(width = 0.2),
    x_label = "Treatment",
    y_label = "Response",
  )

Polygon ggplot

Description

Create a polygon ggplot with a wrapper around ggplot2::ggplot() + geom_polygon().

Usage

gg_polygon(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))

values <- data.frame(
  id = ids,
  value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5)
)

positions <- data.frame(
  id = rep(ids, each = 4),
  x = c(
    2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
    0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3
  ),
  y = c(
    -0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
    2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2
  )
)

datapoly <- merge(values, positions, by = c("id"))

datapoly |>
  gg_polygon(
    x = x,
    y = y,
    col = value,
    group = id,
  )

Qq ggplot

Description

Create a qq ggplot with a wrapper around ggplot2::ggplot() + geom_qq().

Usage

gg_qq(
  data = NULL,
  ...,
  stat = "qq",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_qq(
    sample = body_mass_g,
    facet = species,
    coord = coord_cartesian(clip = "on"),
  ) +
  geom_qq_line()

Quantile ggplot

Description

Create an quantile ggplot with a wrapper around ggplot2::ggplot() + geom_quantile().

Usage

gg_quantile(
  data = NULL,
  ...,
  stat = "quantile",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

if (requireNamespace("quantreg", quietly = TRUE)) {
  library(ggplot2)
  library(palmerpenguins)

  set_blanket()

  penguins |>
    gg_quantile(
      x = flipper_length_mm,
      y = body_mass_g,
    )
}

Raster ggplot

Description

Create a raster ggplot with a wrapper around ggplot2::ggplot() + geom_raster().

Usage

gg_raster(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

faithfuld |>
  gg_raster(
    x = waiting,
    y = eruptions,
    col = density,
  )

Rect ggplot

Description

Create a rect ggplot with a wrapper around ggplot2::ggplot() + geom_rect().

Usage

gg_rect(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

data.frame(
  x = rep(c(2, 5, 7, 9, 12), 2),
  y = rep(c(1, 2), each = 5),
  z = factor(c(rep(1:4, each = 2), 5, NA)),
  w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)
) |>
  mutate(
    xmin = x - w / 2,
    xmax = x + w / 2,
    ymin = y,
    ymax = y + 1
  ) |>
  gg_rect(
    xmin = xmin,
    xmax = xmax,
    ymin = ymin,
    ymax = ymax,
    col = z,
  )

Ribbon ggplot

Description

Create a ribbon ggplot with a wrapper around ggplot2::ggplot() + geom_ribbon()

Usage

gg_ribbon(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

data.frame(year = 1875:1972, level = as.vector(LakeHuron)) |>
  mutate(level_min = level - 1, level_max = level + 1) |>
  gg_ribbon(
    x = year,
    ymin = level_min,
    ymax = level_max,
    x_labels = \(x) x,
  )

Ribbon line ggplot

Description

Create a ribbon line ggplot with a wrapper around ggplot2::ggplot() + geom_smooth(stat = "identity", ...).

Usage

gg_ribbon_line(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

data.frame(year = 1875:1972, level = as.vector(LakeHuron)) |>
  mutate(level_min = level - 1, level_max = level + 1) |>
  gg_ribbon_line(
    x = year,
    y = level,
    ymin = level_min,
    ymax = level_max,
    blend = "multiply",
    se = TRUE,
  )

Rug ggplot

Description

Create a rug ggplot with a wrapper around ggplot2::ggplot() + geom_rug().

Usage

gg_rug(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

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

Segment ggplot

Description

Create a segment ggplot with a wrapper around ggplot2::ggplot() + geom_segment().

Usage

gg_segment(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

data.frame(x1 = 2.62, x2 = 3.57, y1 = 21.0, y2 = 15.0) |>
  gg_segment(
    x = x1,
    xend = x2,
    y = y1,
    yend = y2,
  )

Sf ggplot

Description

Create a blank ggplot with a wrapper around ggplot2::ggplot() + geom_sf().

Usage

gg_sf(
  data = NULL,
  ...,
  stat = "sf",
  position = "identity",
  coord = ggplot2::coord_sf(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

if (requireNamespace("sf", quietly = TRUE)) {
  sf::st_read(system.file("shape/nc.shp", package = "sf")) |>
    gg_sf(
      col = AREA,
    )
}

Smooth ggplot

Description

Create a smooth ggplot with a wrapper around ggplot2::ggplot() + geom_smooth().

Usage

gg_smooth(
  data = NULL,
  ...,
  stat = "smooth",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  gg_smooth(
    x = flipper_length_mm,
    y = body_mass_g,
    col = species,
    se = TRUE,
    blend = "multiply",
  )

Step ggplot

Description

Create a step plot with a wrapper around ggplot2::ggplot() + geom_step().

Usage

gg_step(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()

economics |>
  filter(date > lubridate::ymd("2010-01-01")) |>
  gg_step(
    x = date,
    y = unemploy,
    y_expand_limits = 0,
    y_label = "Unemployment",
  )

Text ggplot

Description

Create a text plot with a wrapper around ggplot2::ggplot() + geom_text().

Usage

gg_text(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)

set_blanket()
set_font_defaults()

bind_rows(
  mtcars |> slice_min(order_by = mpg),
  mtcars |> slice_max(order_by = mpg)
) |>
  tibble::rownames_to_column("themel") |>
  gg_text(
    x = themel,
    y = mpg,
    label = themel,
    y_expand_limits = 0,
    y_label = "Miles per gallon",
    col_palette = c(orange, "white", teal),
  )

Tile ggplot

Description

Create a tile plot with a wrapper around ggplot2::ggplot() + geom_tile().

Usage

gg_tile(
  data = NULL,
  ...,
  stat = "identity",
  position = "identity",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  group_by(species, sex) |>
  summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |>
  gg_tile(
    x = sex,
    y = species,
    col = flipper_length_mm,
  )

Violin ggplot

Description

Create a violin plot with a wrapper around ggplot2::ggplot() + geom_violin().

Usage

gg_violin(
  data = NULL,
  ...,
  stat = "ydensity",
  position = "dodge",
  coord = ggplot2::coord_cartesian(clip = "off"),
  theme = NULL,
  theme_orientation = NULL,
  theme_axis_line_rm = NULL,
  theme_axis_ticks_rm = NULL,
  theme_panel_grid_rm = NULL,
  blend = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_breaks_n = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_label = NULL,
  x_labels = NULL,
  x_position = "bottom",
  x_sec_axis = ggplot2::waiver(),
  x_symmetric = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_breaks_n = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_label = NULL,
  y_labels = NULL,
  y_position = "left",
  y_sec_axis = ggplot2::waiver(),
  y_symmetric = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_breaks_n = 5,
  col_drop = FALSE,
  col_expand_limits = NULL,
  col_label = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_palette = NULL,
  col_palette_na = NULL,
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_drop = FALSE,
  facet_labels = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  label_case = NULL
)

Arguments

data

A data frame or tibble.

...

Other arguments passed to within a params list in layer().

stat

A statistical transformation to use on the data. A snakecase character string of a ggproto Stat subclass object minus the Stat prefix (e.g. "identity").

position

A position adjustment. A snakecase character string of a ggproto Position subclass object minus the Position prefix (e.g. "identity"), or a ⁠position_*()⁠ function that outputs a ggproto Position subclass object (e.g. ggplot2::position_identity()).

coord

A coordinate system. A ⁠coord_*()⁠ function that outputs a constructed ggproto Coord subclass object (e.g. ggplot2::coord_cartesian()).

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that are removed. Either "x" or "y".

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

blend

The blending mode per ggblend::blend() (e.g. "multiply").

x, xmin, xmax, xend, y, ymin, ymax, yend, z, col, facet, facet2, group, subgroup, label, text, sample

An unquoted aesthetic variable.

mapping

A set of additional aesthetic mappings in ggplot2::aes(). Intended primarily for non-supported aesthetics (e.g. shape, linetype, linewidth, or size), but can also be used for delayed evaluation etc.

x_breaks, y_breaks, col_breaks

A ⁠scales::breaks_*⁠ function (e.g. ⁠scales::breaks_*()⁠), or a vector of breaks.

x_breaks_n, y_breaks_n, col_breaks_n

A number of desired breaks for when ⁠*_breaks = NULL⁠.

x_expand, y_expand

Padding to the limits with the ggplot2::expansion() function, or a vector of length 2 (e.g. c(0, 0)).

x_expand_limits, y_expand_limits, col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0). For a discrete scale, manipulate the data instead with forcats::fct_expand.

x_label, y_label, col_label

Label for the axis or legend title. Use + ggplot2::labs(... = NULL) for no title.

x_labels, y_labels, col_labels, facet_labels

A function that takes the breaks as inputs (e.g. ⁠\(x) stringr::str_to_sentence(x)⁠ or ⁠scales::label_*()⁠), or a vector of labels. (Note this must be named for facet_labels).

x_position, y_position

The position of the axis (i.e. "left", "right", "bottom" or "top").If using y_position = "top" with a ⁠*_theme_*⁠ theme, add caption = "" or caption = "\n".

x_sec_axis, y_sec_axis

A secondary axis with ggplot2::dup_axis() or ggplot2::sec_axis().

x_symmetric, y_symmetric

TRUE or FALSE of whether a symmetric scale.

x_transform, y_transform, col_transform

For a continuous scale, a transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

col_drop, facet_drop

For a discrete variable, FALSE or TRUE of whether to drop unused levels.

col_legend_ncol, col_legend_nrow

The number of columns and rows in a legend guide.

col_legend_rev

TRUE or FALSE of whether to reverse the elements of a legend guide. Defaults to FALSE.

col_palette

A character vector of hex codes (or names) or a ⁠scales::pal_*()⁠ function.

col_palette_na

A hex code (or name) for the colour of NA values.

col_rescale

For a continuous variable, a scales::rescale() function.

col_steps

For a continuous variable, TRUE or FALSE of whether to colour in steps. Defaults to FALSE.

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y". Sometimes ⁠+ *_theme_*()⁠ may be needed.

facet_axis_labels

Whether to add interior axis labels with "margins", "all", "all_x", or "all_y".

facet_layout

Whether the layout is to be "wrap" or "grid". If NULL and a single facet (or facet2) argument is provided, then defaults to "wrap". If NULL and both facet and facet2 arguments are provided, defaults to "grid".

facet_ncol, facet_nrow

The number of columns and rows of facet panels. Only applies to a facet layout of "wrap".

facet_scales

Whether facet scales should be "fixed" across facets, "free" in both directions, or free in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

facet_space

When the facet scales are not "fixed", whether facet space should be "fixed" across facets, "free" to be proportional in both directions, or free to be proportional in just one direction (i.e. "free_x" or "free_y"). Defaults to "fixed".

title

Title string.

subtitle

Subtitle string.

caption

Caption title string.

label_case

A function to format the label of unlabelled variables. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket()

penguins |>
  tidyr::drop_na(sex) |>
  gg_violin(
    x = species,
    y = body_mass_g,
    col = sex,
  )

A grey colour

Description

A grey colour.

Usage

grey

Value

A character vector.

Examples

scales::show_col(grey)

The jumble palette

Description

A discrete palette that is relatively colour-blind safe.

Usage

jumble

teal

orange

navy

red

pink

purple

Value

A character vector.

Examples

colorspace::swatchplot(c(jumble, grey), cvd = TRUE)

Label every nth element

Description

Label every nth element in a vector, and replace the rest with "".

Usage

label_every_nth(n = 2, offset = 0, ...)

Arguments

n

The increment of elements to hold as is. Defaults to 2.

offset

An offset for which element to first hold. Defaults to 0. Possible values are -1 to (n - 2)

...

If numeric, arguments passed to the scales::comma function. Otherwise, arguments passed to format.

Value

A labelling function

Examples

label_every_nth()(scales::comma(seq(1000, 5000, 1000)))
 label_every_nth()(lubridate::ymd(c("2021-01-01", "2022-01-01", "2023-01-01", "2024-01-01")))
 label_every_nth()(LETTERS[1:12])

 library(dplyr)
 library(palmerpenguins)

 set_blanket()

 penguins |>
   mutate(across(sex, \(x) stringr::str_to_sentence(x))) |>
   gg_point(
     x = flipper_length_mm,
     y = body_mass_g,
     col = sex,
     x_labels = label_every_nth(),
     y_labels = label_every_nth(),
   )

Light mode theme family

Description

A dark mode family of functions:

  • light_mode_r() with legend on right

  • light_mode_t() with legend on top

  • light_mode_b() with legend on bottom

Usage

light_mode_r(
  ...,
  base_size = 11,
  base_family = "",
  base_colour = "#121B24FF",
  axis_line_colour = "#121B24FF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  panel_grid_colour = "#F6F8FAFF",
  panel_grid_linewidth = 1.33,
  panel_background_fill = "#FFFFFFFF",
  plot_background_fill = "#FFFFFFFF",
  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 = ggplot2::rel(c(0.175, 0))
)

light_mode_t(
  ...,
  base_size = 11,
  base_family = "",
  base_colour = "#121B24FF",
  axis_line_colour = "#121B24FF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  panel_grid_colour = "#F6F8FAFF",
  panel_grid_linewidth = 1.33,
  panel_background_fill = "#FFFFFFFF",
  plot_background_fill = "#FFFFFFFF",
  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 = ggplot2::rel(c(0.175, 0))
)

light_mode_b(
  ...,
  base_size = 11,
  base_family = "",
  base_colour = "#121B24FF",
  axis_line_colour = "#121B24FF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  panel_grid_colour = "#F6F8FAFF",
  panel_grid_linewidth = 1.33,
  panel_background_fill = "#FFFFFFFF",
  plot_background_fill = "#FFFFFFFF",
  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 = ggplot2::rel(c(0.175, 0))
)

Arguments

...

Provided to require argument naming, support trailing commas etc.

base_size

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

base_family

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

base_colour

The base colour of the text theme element.

axis_line_colour

The colour of the axis.line theme element.

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.

panel_grid_colour

The colour of the panel.grid theme element.

panel_grid_linewidth

The linewidth of the panel.grid theme element.

panel_background_fill

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

plot_background_fill

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

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_length

The legend.ticks.length theme element.

Value

A ggplot theme.

Examples

library(palmerpenguins)
library(ggplot2)

set_blanket()

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

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

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

Mode colour and linewidth defaults

Description

lightness and darkness are vectors of 3 colours used in the ⁠*_theme_*⁠ themes for the for the text, axis.line (and axis.ticks), panel.grid, panel.background and plot.background etc.

linewidthness is a vector of 2 integers used in the ⁠*_theme_*⁠ themes for the linewidth of the axis.line (axis.ticks and legend.ticks) and panel.grid theme elements.

Usage

lightness

darkness

linewidthness

Value

A character vector.

Examples

scales::show_col(c(lightness, darkness), ncol = 3)

Set the style

Description

Set the style by setting:

  1. the geom defaults, including the colour (and fill) of geoms (i.e. weave_geom_defaults)

  2. the colour (and fill) palettes (i.e. discrete, continuous and ordinal) (i.e. weave_col_palette)

  3. the theme, and how/what side-effects are to be applied (i.e. weave_theme)

  4. the function to apply to a unspecified/unlabelled x_label, y_label, col_label etc (i.e. weave_label_case).

set_font_defaults() and set_reference_defaults() can be used to customise "text", "label", "abline, "vline" and "hline" geom defaults.

ggplot2::update_geom_defaults() can be used to further fine-tune geom defaults.

Usage

set_blanket(
  ...,
  colour = "#357BA2FF",
  col_palette_d = jumble,
  col_palette_c = viridisLite::mako(n = 9, direction = -1),
  col_palette_o = scales::pal_viridis(option = "G", direction = -1),
  col_palette_na_d = "#CDC5BFFF",
  col_palette_na_c = "#988F88FF",
  col_palette_na_o = "#988F88FF",
  theme = light_mode_r(),
  theme_orientation = NULL,
  theme_axis_line_rm = TRUE,
  theme_axis_ticks_rm = TRUE,
  theme_panel_grid_rm = TRUE,
  label_case = snakecase::to_sentence_case
)

Arguments

...

Provided to require argument naming, support trailing commas etc.

colour

For most geoms, a default hex code for the colour of geoms (i.e. geoms other than "text", "label", "hline", "vline" and "abline"). Note "fill" inherits from this argument.

col_palette_d

For a discrete scale, a character vector of hex codes.

col_palette_c

For a continuous scale, a character vector of hex codes.

col_palette_o

For an ordinal scale, a ⁠scales::pal_*()⁠ function.

col_palette_na_d

For a discrete scale, a hex code.

col_palette_na_c

For a continuous scale, a hex code.

col_palette_na_o

For an ordinal scale, a hex code.

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

theme_orientation

The orientation of plot, which affects the theme components that can be removed by the ⁠gg_*⁠ function. Either "x" or "y". Defaults to NULL, which lets the ⁠gg_*⁠ function guess it based on the data.

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.

label_case

A function to apply to a unspecified/unlabelled x_label, y_label, col_label etc. Defaults to snakecase::to_sentence_case.

Value

A globally set style.

Examples

library(ggplot2)
library(ggblanket)
library(palmerpenguins)

set_blanket(
  theme = dark_mode_r(),
  colour = "#E7298AFF",
  col_palette_d = c("#1B9E77FF", "#D95F02FF", "#7570b3FF", "#E7298AFF",
                    "#66A61EFF", "#E6AB02FF", "#A6761DFF", "#666666FF"),
)

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

penguins |>
  gg_histogram(
    x = flipper_length_mm,
    col = species,
  )

Set the font geom defaults

Description

Update the "text" and "label" geom defaults. Note all other text is controlled by the theme.

Usage

set_font_defaults(
  ...,
  colour = "#121B24FF",
  fill = "#FFFFFFFF",
  size = 11/2.835052,
  family = ""
)

Arguments

...

Provided to require argument naming, support trailing commas etc.

colour

A hex code.

fill

A hex code.

size

A size.

family

A family.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket(theme = dark_mode_r())
set_font_defaults(colour = darkness[1])
set_reference_defaults(colour = darkness[1])

penguins |>
  gg_point(
    x = flipper_length_mm,
    y = body_mass_g,
    x_breaks_n = 4,
  ) +
  geom_vline(xintercept = 200) +
  annotate("text", x = I(0.25), y = I(0.75), label = "Here")

Set reference-line geom defaults

Description

Update the "abline", "hline" and "vline" geom defaults.

Usage

set_reference_defaults(..., colour = "#121B24FF", linewidth = 0.25)

Arguments

...

Provided to require argument naming, support trailing commas etc.

colour

A hex code.

linewidth

A linewidth.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

set_blanket(theme = dark_mode_r())
set_font_defaults(colour = darkness[1])
set_reference_defaults(colour = darkness[1])

penguins |>
  gg_point(
    x = flipper_length_mm,
    y = body_mass_g,
    x_breaks_n = 4,
  ) +
  geom_vline(xintercept = 200) +
  annotate("text", x = I(0.25), y = I(0.75), label = "Here")

Set colour (and fill) palettes

Description

Set colour (and fill) palettes

Usage

weave_col_palette(
  ...,
  col_palette_d = jumble,
  col_palette_c = viridisLite::mako(n = 9, direction = -1),
  col_palette_o = scales::pal_viridis(option = "G", direction = -1),
  col_palette_na_d = "#CDC5BFFF",
  col_palette_na_c = "#988F88FF",
  col_palette_na_o = "#988F88FF"
)

Arguments

...

Provided to require argument naming, support trailing commas etc.

col_palette_d

For a discrete scale, a character vector of hex codes. Use NULL for ggplot2 default. Use NULL to leave as is.

col_palette_c

For a continuous scale, a character vector of hex codes. Use NULL for ggplot2 default. Use NULL to leave as is.

col_palette_o

For an ordinal scale, a ⁠scales::pal_*()⁠ function. Use NULL for ggplot2 default. Use NULL to leave as is.

col_palette_na_d

For a discrete scale, a hex code.

col_palette_na_c

For a continuous scale, a hex code.

col_palette_na_o

For an ordinal scale, a hex code.


Set a series of geom defaults

Description

Update all the geom defaults.

ggplot2::update_geom_defaults() can be used to further fine-tune individual geom defaults.

Usage

weave_geom_defaults(..., colour = "#357BA2FF")

Arguments

...

Provided to require argument naming, support trailing commas etc.

colour

For most geoms, a default hex code for the colour of geoms (i.e. geoms other than "text", "label", "hline", "vline" and "abline"). Note "fill" inherits from this argument.


Set a label case function

Description

Set a function to format the label of unlabelled variables.

Usage

weave_label_case(label_case = snakecase::to_sentence_case, ...)

Arguments

label_case

A function to apply to a unspecified/unlabelled x_label, y_label, col_label etc. Defaults to snakecase::to_sentence_case.

...

Provided to require argument naming, support trailing commas etc.


Set a theme

Description

Set a theme for the theme argument in ⁠gg_*⁠ functions.

Usage

weave_theme(
  theme = light_mode_r(),
  ...,
  theme_orientation = NULL,
  theme_axis_line_rm = TRUE,
  theme_axis_ticks_rm = TRUE,
  theme_panel_grid_rm = TRUE
)

Arguments

theme

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()).

...

Provided to require argument naming, support trailing commas etc.

theme_orientation

The orientation of plot, which affects the theme components that can be removed by the ⁠gg_*⁠ function. Either "x" or "y". Defaults to NULL, which lets the ⁠gg_*⁠ function guess it based on the data.

theme_axis_line_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether the ⁠gg_*⁠ function should remove the relevant panel grid per the theme_orientation of the plot.