Title: Simplify 'ggplot2' Visualisation
Version: 12.4.0
Description: Simplify 'ggplot2' visualisation with 'ggblanket' wrapper functions.
License: MIT + file LICENSE
URL: https://davidhodge931.github.io/ggblanket/, https://github.com/davidhodge931/ggblanket
BugReports: https://github.com/davidhodge931/ggblanket/issues
Depends: R (≥ 4.2.0)
Imports: colorspace, dplyr (≥ 1.0.4), farver, forcats, ggblend, ggplot2 (≥ 3.5.2), grid, hms (≥ 0.5.0), labelled, lubridate (≥ 1.7.8), purrr, rlang (≥ 1.1.0), scales (≥ 1.3.0), snakecase, stringr (≥ 1.3.0), tidyr (≥ 1.0.0), tidyselect (≥ 1.2.0), viridisLite
Suggests: spelling, hexbin, isoband, knitr, palmerpenguins, patchwork, quantreg, rmarkdown, sf, testthat (≥ 3.0.0), tibble, vdiffr, viridis
VignetteBuilder: knitr
Config/Needs/website: concaveman, corrr, farver, ggbeeswarm, ggblend, ggdensity, ggdist, ggeasy, ggforce, ggh4x, gghighlight, ggnewscale, ggrepel, ggridges, ggpattern, glue, marquee, paletteer, showtext, sysfonts
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-GB
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-06-03 02:39:37 UTC; david
Author: David Hodge ORCID iD [aut, cre, cph]
Maintainer: David Hodge <davidhodge931@gmail.com>
Repository: CRAN
Date/Publication: 2025-06-03 04:20:02 UTC

ggblanket: Simplify 'ggplot2' Visualisation

Description

logo

Simplify 'ggplot2' visualisation with 'ggblanket' wrapper functions.

Author(s)

Maintainer: David Hodge davidhodge931@gmail.com (ORCID) [copyright holder]

See Also

Useful links:


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_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_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_contrast(dark = darkness[3], light = darkness[1])),
    position = position_dodge(width = 0.75, preserve = "single"),
    vjust = 1.33,
    show.legend = FALSE,
  )

Annotated axis line 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()

d <- penguins |>
  add_row(
    flipper_length_mm = 175,
    body_mass_g = 2500,
    species = "Adelie",
  )

# axis line goes through geom
d |>
  gg_point(
    x = flipper_length_mm,
    y = body_mass_g,
    col = species,
  )

# axis line does not go through geom
d |>
  gg_blanket(
    x = flipper_length_mm,
    y = body_mass_g,
    col = species,
  ) +
  annotate_axis_line() +
  geom_point()


Bind each all.

Description

Binds data to support plotting each category and all combined data.

Usage

bind_each_all(
  data,
  ...,
  name = "each_all",
  each = "Each",
  all = "All",
  all_after = Inf
)

Arguments

data

A data frame or tibble.

...

An unquoted variable.

name

A variable name. Defaults to each_all.

each

A string for the each value. Defaults to "Each".

all

A string for the all value. Defaults to "All".

all_after

A number for where the all value should be placed after. Use 0 for first or Inf for last. Defaults to Inf.

Value

A data frame or tibble

Examples

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

set_blanket()

penguins |>
  distinct(species)

penguins |>
  bind_each_all(species) |>
  distinct(species, each_all)

penguins |>
  bind_each_all(species) |>
  gg_jitter(
    x = species,
    y = body_mass_g,
  )

penguins |>
  bind_each_all(species) |>
  gg_jitter(
    x = species,
    y = body_mass_g,
    col = each_all,
    col_palette = c(blue, grey),
  ) +
  theme(legend.position = "none")

penguins |>
  bind_each_all(species) |>
  group_by(species, each_all) |>
  summarise(across(body_mass_g, \(x) mean(x, na.rm = TRUE))) |>
  gg_col(
    x = species,
    y = body_mass_g,
    col = each_all,
    col_palette = c(blue, grey),
    width = 0.5,
    y_label = "Average body mass g",
  ) +
  theme(legend.position = "none")

penguins |>
  bind_each_all(species, all = "All\nspecies") |>
  gg_jitter(
    x = species,
    y = body_mass_g,
    col = each_all,
    col_palette = c(blue, grey),
    facet = each_all,
    facet_layout = "grid",
    facet_scales = "free_x",
    facet_space = "free_x",
  ) +
  theme(legend.position = "none") +
  theme(strip.text.x = element_blank()) +
  labs(x = NULL)


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:

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,
  axis_ticks_length = grid::unit(11/3, "pt"),
  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,
  axis_ticks_length = grid::unit(11/3, "pt"),
  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,
  axis_ticks_length = grid::unit(11/3, "pt"),
  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.

axis_ticks_length

The length of the axis.ticks.length 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 theme element.

Value

A ggplot theme.legend.ticks.length

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()
  )


Flexible mode with bottom legend

Description

Flexible mode with legend at bottom.

Usage

flex_mode_b(
  ...,
  base_size = 11,
  base_family = "",
  base_face = "plain",
  base_colour = "#121B24FF",
  plot_title_size = ggplot2::rel(1.1),
  plot_title_family = base_family,
  plot_title_face = "bold",
  plot_title_colour = base_colour,
  plot_subtitle_size = ggplot2::rel(1),
  plot_subtitle_family = base_family,
  plot_subtitle_face = "plain",
  plot_subtitle_colour = base_colour,
  plot_caption_size = ggplot2::rel(0.85),
  plot_caption_family = base_family,
  plot_caption_face = "plain",
  plot_caption_colour = colorspace::lighten(base_colour, 0.1),
  plot_caption_hjust = 0,
  axis_line_colour = "#121B24FF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  axis_ticks_length = grid::unit(3.67, "pt"),
  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_face

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

base_colour

The base colour of the text theme element.

plot_title_size

The size of the plot.title theme element.

plot_title_family

The family of the plot.title theme element.

plot_title_face

The face of the plot.title theme element.

plot_title_colour

The colour of the plot.title theme element.

plot_subtitle_size

The size of the plot.subtitle theme element.

plot_subtitle_family

The family of the plot.subtitle theme element.

plot_subtitle_face

The face of the plot.subtitle theme element.

plot_subtitle_colour

The colour of the plot.subtitle theme element.

plot_caption_size

The size of the plot.caption theme element.

plot_caption_family

The family of the plot.caption theme element.

plot_caption_face

The face of the plot.caption theme element.

plot_caption_colour

The colour of the plot.caption theme element.

plot_caption_hjust

The horizontal adjustment of the plot.caption 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.

axis_ticks_length

The length of the axis.ticks.length 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.


Mode theme base

Description

Theme base for ⁠*_mode_*⁠ functions.

Usage

flex_mode_base(
  base_size = 11,
  base_family = "",
  base_colour = "#121B24FF",
  base_face = "plain",
  plot_title_size = ggplot2::rel(1.1),
  plot_title_family = base_family,
  plot_title_colour = base_colour,
  plot_title_face = "bold",
  plot_subtitle_size = ggplot2::rel(1),
  plot_subtitle_family = base_family,
  plot_subtitle_colour = base_colour,
  plot_subtitle_face = "plain",
  plot_caption_size = ggplot2::rel(0.85),
  plot_caption_family = base_family,
  plot_caption_colour = colorspace::lighten(base_colour, 0.1),
  plot_caption_face = "plain",
  plot_caption_hjust = 0,
  axis_line_colour = "#121B24FF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  axis_ticks_length = grid::unit(11/3, "pt"),
  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

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.

base_face

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

plot_title_size

The size of the plot.title theme element.

plot_title_family

The family of the plot.title theme element.

plot_title_colour

The colour of the plot.title theme element.

plot_title_face

The face of the plot.title theme element.

plot_subtitle_size

The size of the plot.subtitle theme element.

plot_subtitle_family

The family of the plot.subtitle theme element.

plot_subtitle_colour

The colour of the plot.subtitle theme element.

plot_subtitle_face

The face of the plot.subtitle theme element.

plot_caption_size

The size of the plot.caption theme element.

plot_caption_family

The family of the plot.caption theme element.

plot_caption_colour

The colour of the plot.caption theme element.

plot_caption_face

The face of the plot.caption theme element.

plot_caption_hjust

The horizontal adjustment of the plot.caption 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.

axis_ticks_length

The length of the axis.ticks.length 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.


Flexible mode with right legend

Description

Flexible mode with right legend.

Usage

flex_mode_r(
  ...,
  base_size = 11,
  base_family = "",
  base_face = "plain",
  base_colour = "#121B24FF",
  plot_title_size = ggplot2::rel(1.1),
  plot_title_family = base_family,
  plot_title_face = "bold",
  plot_title_colour = base_colour,
  plot_subtitle_size = ggplot2::rel(1),
  plot_subtitle_family = base_family,
  plot_subtitle_face = "plain",
  plot_subtitle_colour = base_colour,
  plot_caption_size = ggplot2::rel(0.85),
  plot_caption_family = base_family,
  plot_caption_face = "plain",
  plot_caption_colour = colorspace::lighten(base_colour, 0.1),
  plot_caption_hjust = 0,
  axis_line_colour = "#121B24FF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  axis_ticks_length = grid::unit(3.67, "pt"),
  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_face

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

base_colour

The base colour of the text theme element.

plot_title_size

The size of the plot.title theme element.

plot_title_family

The family of the plot.title theme element.

plot_title_face

The face of the plot.title theme element.

plot_title_colour

The colour of the plot.title theme element.

plot_subtitle_size

The size of the plot.subtitle theme element.

plot_subtitle_family

The family of the plot.subtitle theme element.

plot_subtitle_face

The face of the plot.subtitle theme element.

plot_subtitle_colour

The colour of the plot.subtitle theme element.

plot_caption_size

The size of the plot.caption theme element.

plot_caption_family

The family of the plot.caption theme element.

plot_caption_face

The face of the plot.caption theme element.

plot_caption_colour

The colour of the plot.caption theme element.

plot_caption_hjust

The horizontal adjustment of the plot.caption 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.

axis_ticks_length

The length of the axis.ticks.length 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.


Flexible mode with top legend

Description

Flexible mode with legend at top.

Usage

flex_mode_t(
  ...,
  base_size = 11,
  base_family = "",
  base_face = "plain",
  base_colour = "#121B24FF",
  plot_title_size = ggplot2::rel(1.1),
  plot_title_family = base_family,
  plot_title_face = "bold",
  plot_title_colour = base_colour,
  plot_subtitle_size = ggplot2::rel(1),
  plot_subtitle_family = base_family,
  plot_subtitle_face = "plain",
  plot_subtitle_colour = base_colour,
  plot_caption_size = ggplot2::rel(0.85),
  plot_caption_family = base_family,
  plot_caption_face = "plain",
  plot_caption_colour = colorspace::lighten(base_colour, 0.1),
  plot_caption_hjust = 0,
  axis_line_colour = "#121B24FF",
  axis_line_linewidth = 0.25,
  axis_ticks_colour = axis_line_colour,
  axis_ticks_linewidth = axis_line_linewidth,
  axis_ticks_length = grid::unit(3.67, "pt"),
  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_face

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

base_colour

The base colour of the text theme element.

plot_title_size

The size of the plot.title theme element.

plot_title_family

The family of the plot.title theme element.

plot_title_face

The face of the plot.title theme element.

plot_title_colour

The colour of the plot.title theme element.

plot_subtitle_size

The size of the plot.subtitle theme element.

plot_subtitle_family

The family of the plot.subtitle theme element.

plot_subtitle_face

The face of the plot.subtitle theme element.

plot_subtitle_colour

The colour of the plot.subtitle theme element.

plot_caption_size

The size of the plot.caption theme element.

plot_caption_family

The family of the plot.caption theme element.

plot_caption_face

The face of the plot.caption theme element.

plot_caption_colour

The colour of the plot.caption theme element.

plot_caption_hjust

The horizontal adjustment of the plot.caption 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.

axis_ticks_length

The length of the axis.ticks.length 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.


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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = qnorm(p = c(0.005, 0.995), mean = 0, sd = 5),
  y_limits_include = 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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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()

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_limits_include = 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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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,
  )


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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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",
  )

 data.frame(year = 1875:1972, level = as.vector(LakeHuron)) |>
  mutate(level_min = level - 1, level_max = level + 1) |>
  gg_smooth(
    stat = "identity",
    x = year,
    y = level,
    ymin = level_min,
    ymax = level_max,
    blend = "multiply",
    se = TRUE,
    x_labels = \(x) x,
  )


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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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()

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_limits_include = 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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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_limits_include = 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_limits_include = 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_limits_include = 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()). (Or a list that includes 1. a theme and 2. a ggplot2::labs() function. E.g. ⁠list(light_mode_r(), labs(colour = NULL, fill = NULL)⁠).

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 to remove the relevant axis line per the theme_orientation of the plot.

theme_axis_ticks_rm

TRUE or FALSE of whether to remove the relevant axis ticks per the theme_orientation of the plot.

theme_panel_grid_rm

TRUE or FALSE of whether to 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_limits_include, y_limits_include, col_limits_include

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)

Guides for legend element colour

Description

Guides to over-ride legend elements with a grey colour

Usage

guides_shape_grey(colour = grey, ...)

guides_linewidth_grey(colour = grey, ...)

guides_size_grey(colour = grey, ...)

Arguments

colour

A default hex code to override the colour of the legend elements. Note, the "fill" inherits from this argument. Defaults to grey.

...

Other arguments passed to ggplot2::guide_legend().

Value

A ggplot guides.

Examples

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

set_blanket()

penguins |>
  drop_na() |>
  gg_jitter(
    x = species,
    y = flipper_length_mm,
    col = island,
    mapping = aes(shape = sex),
  ) +
  guides_shape_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:

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,
  axis_ticks_length = grid::unit(11/3, "pt"),
  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,
  axis_ticks_length = grid::unit(11/3, "pt"),
  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,
  axis_ticks_length = grid::unit(11/3, "pt"),
  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.

axis_ticks_length

The length of the axis.ticks.length 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

Value

A character vector.

Examples

scales::show_col(c(lightness, darkness), ncol = 3)

Symmetric x continuous scale

Description

Create a symmetric continuous x scale for ggplot2 plots. The scale ensures that limits set to the range of breaks with zero expand (where symmetric = TRUE). Note this scale should only be used in plots with geoms with stat = "identity".

Usage

scale_x_symmetric(
  data = NULL,
  x = NULL,
  ...,
  breaks = NULL,
  breaks_n = 6,
  expand = NULL,
  expand_limits = NULL,
  labels = NULL,
  position = "bottom",
  sec_axis = ggplot2::waiver(),
  transform = "identity",
  symmetric = TRUE
)

Arguments

data

A data frame or tibble.

x

An unquoted variable.

...

Provided to force user argument naming etc.

breaks

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

breaks_n

If breaks = NULL, the desired number of breaks.

expand

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

expand_limits

Any values that the limits should encompass (e.g. 0).

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.

position

The position of the axis (i.e. "left", "right", "bottom" or "top").

sec_axis

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

transform

A transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

symmetric

TRUE or FALSE of whether a symmetric scale.

Value

A ggplot2 continuous x scale.

Examples

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

set_blanket()

penguins |>
  ggplot() +
  geom_jitter(aes(x = body_mass_g, y = species, colour = species)) +
  scale_x_symmetric(penguins, body_mass_g) +
  theme(axis.line.x = element_blank()) +
  theme(axis.ticks.x = element_blank()) +
  theme(panel.grid.major.y = element_blank()) +
  theme(axis.ticks.y = element_blank()) +
  coord_cartesian(clip = "off") +
  labs(x = "Body mass g", y = "Species", colour = "Species")


Symmetric y continuous scale

Description

Create a symmetric continuous y scale for ggplot2 plots. The scale ensures that limits set to the range of breaks with zero expand (where symmetric = TRUE). Note this scale should only be used in plots with geoms with stat = "identity". Symmetric y continuous scale

Usage

scale_y_symmetric(
  data = NULL,
  y = NULL,
  ...,
  breaks = NULL,
  breaks_n = 6,
  expand = NULL,
  expand_limits = NULL,
  labels = NULL,
  position = "left",
  sec_axis = ggplot2::waiver(),
  transform = "identity",
  symmetric = TRUE
)

Arguments

data

A data frame or tibble.

y

An unquoted variable.

...

Provided to force user argument naming etc.

breaks

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

breaks_n

If breaks = NULL, the desired number of breaks.

expand

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

expand_limits

Any values that the limits should encompass (e.g. 0).

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.

position

The position of the axis (i.e. "left", "right", "bottom" or "top").

sec_axis

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

transform

A transformation object (e.g. scales::transform_log10()) or character string of this minus the transform_ prefix (e.g. "log10").

symmetric

TRUE or FALSE of whether a symmetric scale.

Value

A ggplot2 continuous y scale.

Examples

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

set_blanket()

penguins |>
  ggplot() +
  geom_point(aes(x = flipper_length_mm, y = body_mass_g, colour = species)) +
  scale_y_symmetric(penguins, body_mass_g) +
  theme(axis.line.y = element_blank()) +
  theme(axis.ticks.y = element_blank()) +
  theme(panel.grid.major.x = element_blank()) +
  coord_cartesian(clip = "off") +
  labs(x = "Flipper length mm", y = "Body mass g", colour = "Species")


Set the style

Description

Set the style by setting:

  1. the geom defaults, including the colour (and fill) of geoms

  2. the colour (and fill) palettes (i.e. discrete, continuous and ordinal)

  3. the theme, and how/what side-effects are to be applied

  4. the function to apply to a unspecified/unlabelled x_label, y_label, col_label etc.

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", and "vline"). Note, the "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,
  )