Skip to contents

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"),
  mode = NULL,
  x = NULL,
  xmin = NULL,
  xmax = NULL,
  xend = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  yend = NULL,
  z = NULL,
  col = NULL,
  alpha = NULL,
  facet = NULL,
  facet2 = NULL,
  group = NULL,
  subgroup = NULL,
  label = NULL,
  text = NULL,
  sample = NULL,
  mapping = NULL,
  x_breaks = NULL,
  x_expand = NULL,
  x_expand_limits = NULL,
  x_labels = NULL,
  x_limits = NULL,
  x_oob = scales::oob_keep,
  x_position = "bottom",
  x_title = NULL,
  x_transform = NULL,
  y_breaks = NULL,
  y_expand = NULL,
  y_expand_limits = NULL,
  y_labels = NULL,
  y_limits = NULL,
  y_oob = scales::oob_keep,
  y_position = "left",
  y_title = NULL,
  y_transform = NULL,
  col_breaks = NULL,
  col_expand_limits = NULL,
  col_labels = NULL,
  col_legend_ncol = NULL,
  col_legend_nrow = NULL,
  col_legend_rev = FALSE,
  col_limits = NULL,
  col_oob = scales::oob_keep,
  col_pal = NULL,
  col_pal_na = "darkgrey",
  col_rescale = scales::rescale(),
  col_steps = FALSE,
  col_title = NULL,
  col_transform = NULL,
  alpha_breaks = NULL,
  alpha_expand_limits = NULL,
  alpha_labels = NULL,
  alpha_legend_ncol = NULL,
  alpha_legend_nrow = NULL,
  alpha_legend_rev = FALSE,
  alpha_limits = NULL,
  alpha_oob = scales::oob_keep,
  alpha_pal = NULL,
  alpha_pal_na = NA,
  alpha_title = NULL,
  alpha_transform = NULL,
  facet_axes = NULL,
  facet_axis_labels = "margins",
  facet_labels = NULL,
  facet_labels_position = "top",
  facet_labels_switch = NULL,
  facet_layout = NULL,
  facet_ncol = NULL,
  facet_nrow = NULL,
  facet_scales = "fixed",
  facet_space = "fixed",
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  titles_to_case = snakecase::to_sentence_case
)

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

mode

A *_mode_* theme (e.g. grey_mode_b(), grey_mode_r(), or dark_mode_r()). This argument adds the theme with side-effects, as the gg_* function will removes selected gridlines/axis-line/ticks. To avoid these side-effects, + the theme on to the output of gg_*.

x

Unquoted x aesthetic variable.

xmin

Unquoted xmin aesthetic variable.

xmax

Unquoted xmax aesthetic variable.

xend

Unquoted xend aesthetic variable.

y

Unquoted y aesthetic variable.

ymin

Unquoted ymin aesthetic variable.

ymax

Unquoted ymax aesthetic variable.

yend

Unquoted yend aesthetic variable.

z

Unquoted z aesthetic variable.

col

Unquoted col aesthetic variable.

alpha

Unquoted alpha aesthetic variable.

facet

Unquoted facet aesthetic variable.

facet2

Unquoted facet2 aesthetic variable.

group

Unquoted group aesthetic variable.

subgroup

Unquoted subgroup aesthetic variable.

label

Unquoted label aesthetic variable.

text

Unquoted text aesthetic variable.

sample

Unquoted sample aesthetic variable.

mapping

Set of additional aesthetic mappings within ggplot2::aes() for non-supported aesthetics (e.g. shape, linetype, linewidth, or size) or for delayed evaluation.

x_breaks, y_breaks

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

x_expand, y_expand

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

x_expand_limits, y_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0).

x_labels, y_labels

A function that takes the breaks as inputs (e.g. \(x) stringr::str_to_sentence(x) or scales::label_comma()), or a vector of labels.

x_limits, y_limits

A vector of length 2 to determine the limits of the axis.

x_oob, y_oob

For a continuous scale variable, a scales::oob_* function of how to handle values outside of limits. Defaults to scales::oob_keep.

x_position, y_position

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

x_title, y_title

Axis title string. Use "" for no title.

x_transform, y_transform

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

col_breaks

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

col_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0).

col_labels

A function that takes the breaks as inputs (e.g. \(x) stringr::str_to_sentence(x) or scales::label_comma()), or a vector of labels.

col_legend_ncol, col_legend_nrow

The number of columns and rows for the legend guide.

col_legend_rev

Reverse the elements of the legend guide. Defaults to FALSE.

col_limits

A vector of length 2 to determine the limits of the axis.

col_oob

For a continuous scale variable, a scales::oob_* function of how to handle values outside of limits. Defaults to scales::oob_keep.

col_pal

Colours to use. A character vector of hex codes (or names).

col_pal_na

Colour to use for NA values. A character vector of a hex code (or name).

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, which colours in a gradient.

col_title

Axis title string. Use "" for no title.

col_transform

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

alpha_breaks

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

alpha_expand_limits

For a continuous variable, any values that the limits should encompass (e.g. 0).

alpha_labels

A function that takes the breaks as inputs (e.g. \(x) stringr::str_to_sentence(x) or scales::label_comma()), or a vector of labels.

alpha_legend_ncol, alpha_legend_nrow

The number of columns and rows for the legend guide.

alpha_legend_rev

Reverse the elements of the legend guide. Defaults to FALSE.

alpha_limits

A vector of length 2 to determine the limits of the axis.

alpha_oob

For a continuous scale variable, a scales::oob_* function of how to handle values outside of limits. Defaults to scales::oob_keep.

alpha_pal

Alpha values to use. For a continuous variable, a vector of length 2 between 0 and 1. For a discrete variable, a vector of integers between 0 and 1.

alpha_pal_na

Alpha value to use for the NA value. A integer between 0 and 1.

alpha_title

Axis title string. Use "" for no title.

alpha_transform

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

facet_axes

Whether to add interior axes and ticks with "margins", "all", "all_x", or "all_y".

facet_axis_labels

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

facet_labels

A function that takes the breaks as inputs (e.g. \(x) stringr::str_to_sentence(x)), or a named vector of labels (e.g. c("value1" = "label1", ...)).

facet_labels_position

When the facet layout is "wrap", the position of the facet labels. Either "top", "right", "bottom" or "left".

facet_labels_switch

When the facet layout is "grid", whether to switch the facet labels to the opposite side of the plot. Either "x", "y" or "both".

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

The number of columns of facets. Only applies to a facet layout of "wrap".

facet_nrow

The number of rows of facets. 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 layout is "grid" and 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.

titles_to_case

A function to format unspecified titles_to_case. Defaults to snakecase::to_sentence_case.

Value

A ggplot object.

Examples


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

penguins |>
  mutate(across(sex, \(x) stringr::str_to_sentence(x))) |>
  gg_point(
    x = flipper_length_mm,
    y = body_mass_g,
    col = sex,
  )
#> Warning: Ignoring unknown parameters: `contour`
#> Warning: Ignoring unknown parameters: `contour`
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).