Learn R Programming

barrel (version 0.1.0)

barrel_label_axes: 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)

Value

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

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.

See Also

get_ord_axis_labels

Examples

Run this code
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))

Run the code above in your browser using DataLab