Skip to contents

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.

Examples

library(ggplot2)

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

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