factoextra
factoextra copied to clipboard
removing legend from PCA plot ?
Hi,
I am using function fviz_pca_ind
, and was wondering if there's way to specify not showing the group legend. As advised in issue https://github.com/kassambara/factoextra/issues/20, I tried show.legend.text = FALSE
, but didn't work, showing error:
"geom_text requires the following missing aesthetics: label"
My code looks like this:
res.pca <- prcomp(data, scale = TRUE)
fviz_pca_ind(res.pca, habillage = rownames(data), repel = TRUE) +
scale_colour_manual(values=my_color) + geom_text(show.legend.text= F)
What am I doing wrong? Thank you!
Shuonan
I had the same problem and how did you solve it? thanks!
Have you tried:
fviz_pca_ind(res.pca, habillage = rownames(data), repel = TRUE) + scale_colour_manual(values=my_color) + theme(legend.position = "none")
It works with ggplot, therefore that is possible. Hope it works for you!
I realise this might be too late for the original poster, but by adding
+guides(shape=”none”, fill=”none”)
to the end of your fviz_pca_ind code, it should get rid of the Group legend.