rpcafactoextra

PCA analysis remove centroid


I am using fviz_pca_ind to make PCA plot see below.

 fviz_pca_ind(res.pca,  geom="point",  pointsize = 1, habillage=iris$Species, addEllipses=TRUE, ellipse.level=0.95
             , palette = c("green", "orange", "grey")) 

I want to remove the centroid but maintain the different colors and ellipses that I get with habillage=iris$Species.

col.ind requires a vector with a number of elements equal to the lines number.


Solution

  • Here is a way to remove centroids:

    library(factoextra)
    data(iris)
    res.pca <- prcomp(iris[, -5],  scale = TRUE)
    fviz(res.pca, element="ind", geom="point",  pointsize = 1, 
                  habillage=iris$Species, addEllipses=TRUE, ellipse.level=0.95, 
                  palette = c("green", "orange", "grey"), invisible="quali") 
    

    enter image description here