barrel_label_axes: Add Axis Titles with Method Name and Explained Variance

View source: R/8.barrel_label_axes.R

barrel_label_axesR Documentation

Add Axis Titles with Method Name and Explained Variance

Description

This function creates properly formatted axis titles for ordination plots. It uses the ordination method name (e.g., RDA, dbRDA, NMDS) and, when available, the percentage of variance explained by the first two axes.

Usage

barrel_label_axes(ord)

Arguments

ord

A vegan ordination object, such as from rda(), cca(), capscale(), or metaMDS().

Details

The labels are retrieved using get_ord_axis_labels and returned as a ggplot2::labs() object that can be added to a plot.

Value

A ggplot2::labs() object with x and y axis titles.

See Also

get_ord_axis_labels

Examples

library(vegan)
library(ggplot2)
data(dune)
data(dune.env)

# Example with RDA
ord <- rda(dune)
scores_df <- as.data.frame(scores(ord, display = "sites"))
scores_df$Management <- dune.env$Management

ggplot(scores_df, aes(x = PC1, y = PC2, color = Management)) +
  geom_point() +
  barrel_label_axes(ord) +
  theme_minimal() +
  theme(axis.title = element_text(face = "bold", size = 13))


barrel documentation built on Nov. 5, 2025, 7:40 p.m.