Reputation: 1814
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.
Upvotes: 6
Views: 5065
Reputation: 188
There is in fact a much simpler way directly in the fviz_pca_ind (and fviz_pca_biplot) function: "To remove the group mean point, specify the argument mean.point = FALSE." (source). So:
library(factoextra)
data(iris)
res.pca <- prcomp(iris[, -5], scale = TRUE)
fviz_pca_ind(res.pca, geom="point", pointsize = 1, habillage=iris$Species, addEllipses=TRUE,
ellipse.level=0.95, palette = c("green", "orange", "grey"), mean.point=F)
Upvotes: 3
Reputation: 24252
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")
Upvotes: 7