【问题标题】:Customization of pointshape within function fviz_pca from FactoExtra packageFactoExtra 包中函数 fviz_pca 中点形状的自定义
【发布时间】:2018-10-31 03:28:57
【问题描述】:

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

该图以我要自定义的点形状的特定顺序*显示。

*对应的形状分别是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()

我尝试添加到函数中:

  geom_point(aes(shape = c(19,20,21,22,23,24)))

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

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

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

【问题讨论】:

    标签: r pca ggpubr


    【解决方案1】:

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

    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))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-17
      • 2020-04-12
      • 2012-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多