| barrel_stats | R Documentation |
Combines ordination ellipses, centroids, environmental arrows, and annotations into a ggplot2 layer.
stat_barrel(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
kind = "se",
conf = 0.95,
method = c("robust", "classic"),
show.legend = NA,
inherit.aes = TRUE,
geom_type = c("path", "polygon"),
...
)
stat_barrel_centroid(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
method = c("classic", "robust"),
show.legend = NA,
inherit.aes = TRUE,
shape = 3,
...
)
stat_barrel_arrows(
mapping = NULL,
data = NULL,
ord,
matrix,
geom = "segment",
position = "identity",
labels = TRUE,
labels.color = "black",
labels.size = 3,
labels.fontface = "plain",
show.significant = FALSE,
p_thresh = 0.05,
arrow = grid::arrow(length = grid::unit(0.25, "cm")),
arrow.color = "grey10",
arrow.linetype = "solid",
arrow.size = 0.3,
labels.max.overlaps = Inf,
show.legend = NA,
inherit.aes = TRUE,
...
)
compute_envfit_vectors(ord, matrix, p_thresh = 0.05, show.significant = FALSE)
stat_barrel_annotate(
mapping = NULL,
data = NULL,
ord,
position = "identity",
show.legend = FALSE,
inherit.aes = TRUE,
xpad = 0.05,
ypad = 0.05,
hjust = 0,
vjust = 1,
...
)
mapping |
Set of aesthetic mappings created by |
data |
Data frame used for plotting. |
geom |
Character; geometric object to use for ellipses, either |
position |
Position adjustment for ggplot2 layers (default |
kind |
Character; type of ellipse: |
conf |
Numeric; confidence level for ellipses (default 0.95). |
method |
Character; covariance estimation method: |
show.legend |
Logical; whether to show legends (default |
inherit.aes |
Logical; whether to inherit aesthetics (default |
geom_type |
Character; geometric object to use for ellipses, either |
... |
Additional parameters passed to underlying geoms or stats. |
shape |
Integer; shape code for centroid points (default 3). |
ord |
Ordination object from vegan, e.g. |
matrix |
Optional data frame of environmental variables for arrows. |
labels |
Logical; whether to show labels on environmental arrows (default |
labels.color |
Color of arrow labels (default |
labels.size |
Numeric size of arrow labels (default 3). |
labels.fontface |
Font face of arrow labels (default |
show.significant |
Logical; whether to show only significant arrows (default |
p_thresh |
Numeric; p-value threshold for significance filtering (default 0.05). |
arrow |
A grid arrow object controlling arrow appearance (default created by |
arrow.color |
Color of arrows (default |
arrow.linetype |
Line type of arrows (default |
arrow.size |
Numeric line width of arrows (default 0.3). |
labels.max.overlaps |
Maximum number of labels in the same space (default |
xpad |
Numeric; horizontal padding for annotation text relative to x-axis range (default 0.05). |
ypad |
Numeric; vertical padding for annotation text relative to y-axis range (default 0.05). |
hjust |
Numeric; horizontal justification of annotation text (default 0). |
vjust |
Numeric; vertical justification of annotation text (default 1). |
Comprehensive Ordination Visualization Layer
This set of ggplot2 stats draws ellipses around groups, centroids, environmental arrows, and adds adjusted R^2 or stress annotation for ordination objects from vegan.
A ggplot2 layer combining ellipses, centroids, arrows, and annotations.
library(ggplot2)
library(vegan)
library(robustbase)
data(dune)
data(dune.env)
pca <- vegan::rda(dune, scale = TRUE)
scores <- as.data.frame(vegan::scores(pca, display = "sites"))
scores$Management <- dune.env$Management
ggplot(scores, aes(PC1, PC2, group = Management, fill = Management)) +
stat_barrel(
method = "classic", kind = "se", conf = 0.95, geom_type = "polygon",
alpha = 0.4, color = "black"
) +
stat_barrel_centroid(method = "classic", shape = 3) +
stat_barrel_arrows(
ord = pca, matrix = dune,
labels = TRUE, labels.color = "blue",
arrow.color = "darkred", arrow.linetype = "solid",
labels.fontface = "bold", show.significant = TRUE,
labels.max.overlaps = Inf,
) +
stat_barrel_annotate(ord = pca, xpad = 0.05, ypad = 0.05) +
geom_point(aes(color = Management)) +
theme_minimal()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.