Skip to contents

geom_sketch_ecdf() draws the empirical CDF of a continuous variable as a hand-drawn stairstep - the sketch analogue of ggplot2::stat_ecdf() / geom_step(stat = "ecdf"). Needs an x aesthetic; each group gets its own curve.

Usage

geom_sketch_ecdf(
  mapping = NULL,
  data = NULL,
  stat = "ecdf",
  position = "identity",
  ...,
  n = NULL,
  pad = FALSE,
  roughness = 0.8,
  bowing = 0.5,
  n_passes = 2L,
  seed = NULL,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by ggplot2::aes().

data

Data to display.

stat

Statistical transformation. Default "identity".

position

Position adjustment. Default "identity".

...

Other arguments passed on to the layer.

n

If NULL (default), the ECDF jumps at each observed value; otherwise the curve is evaluated at n evenly spaced points (passed to ggplot2::stat_ecdf()).

pad

If TRUE, add -Inf/Inf plateaus at the ends. Default FALSE (the roughened line spans the data range only, avoiding infinite coordinates).

roughness

Non-negative roughness (0 = straight). Default 1. For geom_sketch_segment() this is a mappable aesthetic (map it per segment with aes(roughness = ), rescaled by scale_roughness_continuous()); for geom_sketch_step() it is a layer parameter (one path per group).

bowing

Non-negative bowing multiplier. Default 1.

n_passes

Number of stroke passes. Default 2.

seed

Integer seed. NULL uses getOption("ggsketch.seed", 1L).

na.rm

Remove missing values silently? Default FALSE.

show.legend

Logical; include in legend?

inherit.aes

Override default aesthetics?

Value

A ggplot2 layer object.

Examples

library(ggplot2)
ggplot(mtcars, aes(mpg)) +
  geom_sketch_ecdf(colour = "#2E86C1", seed = 1L) +
  theme_sketch()