Skip to contents

StatCutoff calls the same cutoff_plan() used by show_cutoffs(), but the two interfaces deliberately operate at different scopes. ggplot2 supplies a stat with one panel's rows at a time, so this stat computes panel-local cutoffs. show_cutoffs() plans once from the whole resolved distribution and repeats those global marks across facets.

Usage

StatCutoff

stat_cutoff(
  mapping = NULL,
  data = NULL,
  geom = "cutoff",
  position = "identity",
  ...,
  part = "middle",
  prop = 0.95,
  greedy = TRUE,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Format

StatCutoff is a ggplot2::Stat object.

Arguments

mapping

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

data

The data to be displayed in this layer.

geom

The geometric object used to display the data. Defaults to "cutoff".

position

A position adjustment. Defaults to "identity".

...

Other arguments passed to ggplot2::layer().

part

The distribution part to mark: "middle", "tails", "upper", "lower", or "outer".

prop

The requested proportion. The endpoints 0 and 1 are valid for this lower-level stat.

greedy

Whether a fractional observation is included in the selected region.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

show.legend

Logical. Should this layer be included in the legends?

inherit.aes

If FALSE, override the default aesthetics rather than combining with them.

Value

stat_cutoff() returns a ggplot2 layer.

Details

The stat accepts "middle", "tails", "upper", "lower", and "outer". It selects cutoffs in the data's original space: transformed position values are inverted before cutoff_plan() runs, and the selected cutoffs are transformed forward again for ggplot2. This preserves the requested distribution part on increasing, decreasing, and transformed scales.

stat_cutoff() is the conventional layer constructor. Its default geom is "cutoff"; use geom = "vline" when a full-height reference line is wanted instead. Since the stat computes once per panel, styling aesthetics from the source data cannot be mapped; set them to one value, or facet the plot to compute one set of cutoffs per group.

See also

show_cutoffs(), which marks whole-distribution cutoffs.