geom_crossbar_predefined: Add crossbar to ggplot

View source: R/themes.R

geom_crossbar_predefinedR Documentation

Add crossbar to ggplot

Description

Adds a crossbar to a ggplot. Best used when comparing one categorical and one numeric variable using geom_point / geom_jitter(height=0).

Usage

geom_crossbar_predefined(
  summaryfunction = stats::median,
  width = 0.4,
  size = 0.3,
  colour
)

Arguments

summaryfunction

a function run on the y aesthetic to determine where line is drawn. Options include median, mean, max, min, or any other function that summarises a numeric vector into a single number (function)

width

width of crossbar

size, colour

ggplot aesthetics

Value

ggplot geom

Examples

mtcars %>%
  ggplot2::ggplot(ggplot2::aes(cyl>6, mpg)) +
  ggplot2::geom_point() +
  geom_crossbar_predefined()

selkamand/utilitybeltgg documentation built on July 14, 2022, 2:32 p.m.