| plot_category_space | R Documentation |
Creates a ggplot2 visualization of one or two acoustic dimensions from a token-level table. One-dimensional inputs are plotted as density curves; two-dimensional inputs are plotted as category-colored scatterplots with optional normal ellipses.
plot_category_space(
data,
features,
category_col,
group_col = NULL,
points = TRUE,
ellipses = TRUE,
point_alpha = 0.65,
point_size = 1.8,
reverse_x = FALSE,
reverse_y = FALSE,
equal_axes = FALSE,
facet_scales = c("fixed", "free", "free_x", "free_y")
)
data |
Data frame containing category labels and acoustic features. |
features |
One or two numeric feature columns to plot. |
category_col |
String; category column. |
group_col |
Optional grouping column used for facets. |
points |
Logical; if |
ellipses |
Logical; if |
point_alpha |
Point transparency. |
point_size |
Point size. |
reverse_x |
Logical; if |
reverse_y |
Logical; if |
equal_axes |
Logical; if |
facet_scales |
Scales passed to |
A ggplot2 plot object.
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_category_space(vowels, features = "f1", category_col = "vowel")
plot_category_space(
vowels,
features = c("f2", "f1"),
category_col = "vowel",
reverse_x = TRUE,
reverse_y = TRUE
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.