I have been struggling to make a change on the default point shape that comes in the output plot within the function fviz_pca
from the R package FactoExtra
.
The plot appears with a certain order* of point shapes which I want to customize.
*The corresponding shapes are respectively 16,17,15,12,0,8
fviz_pca_biplot(PCA, axes = c(1, 2),
label="var", col.var = "black", #setas
geom = "point", pointsize = 2, col.ind=PCADF$groups,
addEllipses = TRUE, ellipse.level = 0.95,
ellipse.type ="confidence", palette = "aaas") + theme_minimal()
I tried add to the function:
geom_point(aes(shape = c(19,20,21,22,23,24)))
and it returned me a error message:
Error in geom[1] : object of type 'environment' is not subsettable
Any advice to manage and customize the pointshapes within the function fviz_pca?
We can use scale_shape_manual()
just like with a ggplot2
object:
library(factoextra)
data(iris)
res.pca <- prcomp(iris[, -5], scale = TRUE)
fviz_pca_ind(res.pca,axes = c(1, 2),
label="var", col.var = "black", #setas
geom = "point", pointsize = 2, col.ind=iris$Species,
addEllipses = TRUE, ellipse.level = 0.95,
ellipse.type ="confidence", palette = "aaas") + theme_minimal()+
scale_shape_manual(values=c(19,20,21))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With