Learn R Programming

factoextra (version 1.0.3)

fviz_add: Add supplementary data to a plot

Description

Add supplementary data to a plot

Usage

fviz_add(ggp, df, axes = c(1, 2), geom = c("point", "arrow"), color = "blue", addlabel = TRUE, labelsize = 4, pointsize = 2, shape = 19, linetype = "dashed", jitter = list(what = "label", width = NULL, height = NULL))

Arguments

ggp
a ggplot2 plot.
df
a data frame containing the x and y coordinates
axes
a numeric vector of length 2 specifying the components to be plotted.
geom
a character specifying the geometry to be used for the graph Allowed values are "point" or "arrow" or "text"
color
the color to be used
addlabel
a logical value. If TRUE, labels are added
labelsize
the size of labels. Default value is 4
pointsize
the size of points
shape
point shape when geom ="point"
linetype
the linetype to be used when geom ="arrow"
jitter
a parameter used to jitter the points in order to reduce overplotting. It's a list containing the objects what, width and height (i.e jitter = list(what, width, height)).
  • what: the element to be jittered. Possible values are "point" or "p"; "label" or "l"; "both" or "b".
  • width: degree of jitter in x direction
  • height: degree of jitter in y direction

Value

a ggplot2 plot

References

http://www.sthda.com

Examples

Run this code

# 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)
fviz_add(p, coord, color ="blue", geom="arrow") 
 
 

Run the code above in your browser using DataLab