Skip to contents

Hand-drawn uncertainty intervals at each x: geom_sketch_linerange() draws a vertical range from ymin to ymax; geom_sketch_pointrange() adds a point at y; geom_sketch_errorbar() adds end caps; geom_sketch_crossbar() draws a rough box with a line at y. Sketch analogues of ggplot2::geom_linerange() and friends. Vertical orientation only in this release.

Usage

GeomSketchLinerange

GeomSketchPointrange

GeomSketchErrorbar

GeomSketchCrossbar

geom_sketch_linerange(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  roughness = 0.7,
  bowing = 1,
  n_passes = 2L,
  seed = NULL,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

geom_sketch_pointrange(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  fatten = 4,
  roughness = 0.7,
  bowing = 1,
  n_passes = 2L,
  seed = NULL,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

geom_sketch_errorbar(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  width = 0.5,
  roughness = 0.7,
  bowing = 1,
  n_passes = 2L,
  seed = NULL,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

geom_sketch_crossbar(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  width = 0.5,
  roughness = 0.7,
  bowing = 1,
  n_passes = 2L,
  seed = NULL,
  fill_style = "solid",
  hachure_angle = 45,
  hachure_gap = NULL,
  fill_weight = 0.5,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping, data, stat, position, na.rm, show.legend, inherit.aes, ...

Standard layer arguments.

roughness, bowing, n_passes, seed

Sketch parameters.

fatten

For pointrange, multiply the point size by this factor.

width

For errorbar/crossbar, the cap/box width in data units.

fill_style, hachure_angle, hachure_gap, fill_weight

Fill parameters for the crossbar box.

Value

A ggplot2 layer object.

Examples

library(ggplot2)
df <- data.frame(x = c("a", "b", "c"), y = c(2, 5, 4),
                 lo = c(1, 4, 2.5), hi = c(3, 6, 5.5))
ggplot(df, aes(x, y)) +
  geom_sketch_pointrange(aes(ymin = lo, ymax = hi), seed = 1L) +
  theme_sketch()