plot_rank_agreement: Rank-agreement plot for a speaker ranking

View source: R/ranking_plots.R

plot_rank_agreementR Documentation

Rank-agreement plot for a speaker ranking

Description

Draws step 3 of the ranking protocol behind rank_contrasts(): each speaker's Pillai percentile rank against its Jensen-Shannon distance percentile rank, the identity line on which the two measures agree, and the inspection band of margin either side of it. Speakers outside the band are flagged; speakers the bandwidth check set aside are crossed; speakers whose flag may not be read at this sample size and dimensionality are hollow. Speakers at the \sqrt{JSD} ceiling have no rank and are listed in the caption instead of drawn.

Usage

plot_rank_agreement(
  ranking,
  label = c("flagged", "all", "none"),
  base_size = 12
)

Arguments

ranking

A phontrast_ranking object from rank_contrasts().

label

Which speakers to name on the plot: "flagged" (default: flagged or set-aside speakers), "all", or "none".

base_size

Base font size passed to theme_phontrast().

Value

A ggplot2 plot object.

See Also

rank_contrasts(), inspect_contrast().

Examples

set.seed(2026)
gaps <- c(30, 60, 90, 120, 150, 180, 210, 240)
cohort <- do.call(rbind, lapply(seq_along(gaps), function(i) {
  data.frame(
    speaker = sprintf("s%02d", i),
    vowel = rep(c("ih", "eh"), each = 50),
    f1 = c(rnorm(50, 500, 55), rnorm(50, 500 + gaps[i], 55)),
    f2 = c(rnorm(50, 1900, 120), rnorm(50, 1900 - gaps[i], 120))
  )
}))
ranking <- rank_contrasts(cohort, c("f1", "f2"), "vowel", "speaker",
                          bw_check = FALSE)
if (requireNamespace("ggplot2", quietly = TRUE)) {
  plot_rank_agreement(ranking, label = "all")
}

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