在 FactoExtra 包中的 fviz_pca 函数中自定义点形状

Jul*_*ves 8 r pca ggpubr

我一直在努力对fviz_pca来自 R 包的函数内的输出图中的默认点形状进行更改FactoExtra

该图以我想要自定义的点形状的特定顺序*出现。

*对应的形状分别为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()
Run Code Online (Sandbox Code Playgroud)

我尝试添加到函数中:

  geom_point(aes(shape = c(19,20,21,22,23,24)))
Run Code Online (Sandbox Code Playgroud)

它向我返回了一条错误消息:

geom[1] 中的错误:“环境”类型的对象不是可子集的

在函数 fviz_pca 中管理和自定义点形状的任何建议?

J.C*_*Con 7

我们可以scale_shape_manual()像使用ggplot2对象一样使用:

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))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述