plot.phontrast_contrast: Plot a phontrast() result directly

View source: R/plotting.R

plot.phontrast_contrastR Documentation

Plot a phontrast() result directly

Description

phontrast() results carry the class "phontrast_contrast", so they can be plotted without an explicit call to plot_overlap_metrics(): plot(phontrast(...)) draws the metric comparison, and ggplot2::autoplot(phontrast(...)) returns the same plot unprinted for further composition.

Usage

## S3 method for class 'phontrast_contrast'
plot(x, ...)

## S3 method for class 'phontrast_contrast'
autoplot(object, ...)

Arguments

x, object

A phontrast_contrast object returned by phontrast().

...

Passed on to plot_overlap_metrics().

Value

plot() draws the plot and returns it invisibly; autoplot() returns the ggplot2 object unprinted.

Examples

set.seed(2026)
vowels <- data.frame(
  vowel = rep(c("ih", "eh"), each = 40),
  f1 = c(rnorm(40, 500, 55), rnorm(40, 565, 60)),
  f2 = c(rnorm(40, 1980, 150), rnorm(40, 1870, 155))
)
if (requireNamespace("ggplot2", quietly = TRUE)) {
  plot(phontrast(vowels, c("f1", "f2"), "vowel", output = "long"))
}

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