Add supplementary data to a plot
a ggplot2 plot.
a data frame containing the x and y coordinates
a numeric vector of length 2 specifying the components to be plotted.
a character specifying the geometry to be used for the graph Allowed values are "point" or "arrow" or "text"
the color to be used
a logical value. If TRUE, labels are added
the size of labels. Default value is 4
the size of points
point shape when geom ="point"
the linetype to be used when geom ="arrow"
a boolean, whether to use ggrepel to avoid overplotting text
labels or not. The old jitter argument is kept for backward
compatibility and is converted to repel = TRUE with a deprecation warning.
character vector specifying font family.
Additional arguments, not used
a ggplot2 plot
# \donttest{
# Principal component analysis
data(decathlon2)
decathlon2.active <- decathlon2[1:23, 1:10]
res.pca <- prcomp(decathlon2.active, scale = TRUE)
# Visualize variables
p <- fviz_pca_var(res.pca)
print(p)
# Add supplementary variables
coord <- data.frame(PC1 = c(-0.7, 0.9), PC2 = c(0.25, -0.07))
rownames(coord) <- c("Rank", "Points")
print(coord)
#> PC1 PC2
#> Rank -0.7 0.25
#> Points 0.9 -0.07
fviz_add(p, coord, color ="blue", geom="arrow")
# }