我一直在努力对来自R包fviz_pca
的函数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()
我尝试添加到该功能:
geom_point(aes(shape = c(19,20,21,22,23,24)))
它返回了一条错误消息:
geom [1]出错:'environment'类型的对象不是子集
在fviz_pca函数中管理和自定义点形状的任何建议?
答案 0 :(得分:0)
我们可以像使用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))