plot_overlap_metrics: Plot overlap metric comparisons

View source: R/plotting.R

plot_overlap_metricsR Documentation

Plot overlap metric comparisons

Description

Visualizes the output of phontrast() with ggplot2. The input may be either wide or long output. By default, values are plotted on a separation-oriented scale so overlap-oriented metrics are transformed as 1 - estimate.

Usage

plot_overlap_metrics(
  metrics,
  value = c("separation", "estimate"),
  metric = NULL,
  group_col = NULL,
  show_ci = TRUE,
  facet = TRUE,
  sort = TRUE
)

Arguments

metrics

Data frame returned by phontrast().

value

Scale to plot: "separation" plots separation_value; "estimate" plots raw metric estimates.

metric

Optional character vector of metric display names to include.

group_col

Optional column to use on the x-axis. Defaults to "group" when present, then "scope".

show_ci

Logical; if TRUE, draw confidence intervals when ci_lower/ci_upper columns are present.

facet

Logical; if TRUE, facet by metric.

sort

Logical; if TRUE, order comparisons by their mean plotted value.

Value

A ggplot2 plot object.

Examples

set.seed(2026)
vowels <- data.frame(
  speaker = rep(c("s01", "s02"), each = 60),
  vowel = rep(rep(c("ih", "eh"), each = 30), 2),
  f1 = c(rnorm(30, 500, 55), rnorm(30, 560, 60),
         rnorm(30, 510, 60), rnorm(30, 575, 65)),
  f2 = c(rnorm(30, 1980, 150), rnorm(30, 1880, 155),
         rnorm(30, 1960, 160), rnorm(30, 1840, 165))
)

metrics <- phontrast(
  vowels,
  features = c("f1", "f2"),
  category_col = "vowel",
  group_col = "speaker",
  output = "long"
)

if (requireNamespace("ggplot2", quietly = TRUE)) {
  plot_overlap_metrics(metrics)
}

phontrast documentation built on Oct. 7, 2026, 5:06 p.m.