I am trying to assign different colors for variables in a PCA biplot. However, fviz_pca_biplot
from the R package factoextra
can not plot the correct color for each variable.
library(factoextra)
data(iris)
res.pca <- prcomp(iris[, -5], retx = TRUE, center = TRUE, scale. = TRUE)
res.pca
my.col.var <- c("red", "blue", "red", "yellow")
fviz_pca_biplot(res.pca, repel = TRUE, axes = c(1, 2),
col.var = my.col.var, col.ind = "#696969",
label = "var", title = "")
I have assigned "red", "blue", "red", "yellow" for variables "Sepal.Length", "Sepal.Width", "Petal.Length", and "Petal.Width". However, the figure shows wrong colors for all variables.