add_vertex_labels: Add vertex labels to ternary plot

View source: R/add_vertex_labels.R

add_vertex_labelsR Documentation

Add vertex labels to ternary plot

Description

Adds text labels at the vertices of a ternary simplex with automatic positioning adjustments.

Usage

add_vertex_labels(
  vertex_labels_df,
  nudge_x = c(-0.02, 0.02, 0),
  nudge_y = c(-0.05, -0.05, 0.05),
  ...
)

Arguments

vertex_labels_df

A data frame containing vertex coordinates and labels. Should have columns x1, x2, and labels. Can be specified manually or obtained from a ternable object: ternable_object$simplex_vertices.

nudge_x

Numeric vector of length 3 specifying horizontal nudges for each vertex label.

nudge_y

Numeric vector of length 3 specifying vertical nudges for each vertex label.

...

Arguments passed to ggplot2::geom_text(), such as size, colour, fontface, etc.

Value

A ggplot object

Examples

library(ggplot2)

# Create a ternable object
tern <- as_ternable(prefviz::aecdop22_transformed, ALP:Other)

ggplot() +
  add_ternary_base() +
  add_vertex_labels(tern$simplex_vertices, size = 5, fontface = "bold")


prefviz documentation built on April 13, 2026, 5:07 p.m.