英文:
Keep mean points only for individual-groups in {factoextra} PCA biplot
问题
我使用鸢尾花数据集作为示例。我已设置mean.point-TRUE
,这将为setosa(红色圆点),versicolor(绿色三角形),virginica(蓝色正方形)以及因子(钢蓝色点)提供均值点。我希望使钢蓝色点不显示,同时保持其他内容不变。我该如何做?
以下是代码部分:
library(tidyverse)
library(factoextra)
library(FactoMineR)
Groups <- as.factor(iris$Species)
res.pca <- prcomp(iris[-5], scale. = TRUE, center = TRUE)
fviz_pca_biplot(res.pca,
mean.point = TRUE,
pointsize = 1,
habillage = Groups,
addEllipses = TRUE,
label = FALSE)
以下是输出部分:
英文:
I use the iris dataset as an example. I have set mean.point-TRUE
which gives mean points for setosa (red round), versicolor (green triangle), virginica (blue square) as well as the factors (steelblue dot). I wish to make the steelblue dot to not appear while keeping everything else as is. How do I do this?
Here is the code:
library(tidyverse)
library(factoextra)
library(FactoMineR)
Groups<-as.factor(iris$Species)
res.pca<-prcomp(iris[-5], scale. = TRUE, center = TRUE)
fviz_pca_biplot(res.pca,
mean.point=TRUE,
pointsize=1,
habillage=Groups,
addEllipses = TRUE,
label = FALSE)
And here is the output:
答案1
得分: 1
你可以为平均点分配不同的大小。在你的示例中,蓝色点是第三组的平均值,所以你可以将大小向量的第三个位置设为零以隐藏该点:
fviz_pca_biplot(## ...其他参数
## 但不包括 mean.point
mean.point.size = c(5, 5, 0)
)
(完全省略 mean.point
参数,即不将其设置为 TRUE
、FALSE
或任何其他缺失值)
英文:
You can assign separate sizes to mean points. In your example, the blue point is the mean of the third group, so you can set the third position of the size vector to zero to hide the point:
fviz_pca_biplot(## ... other arguments
## but without mean.point
mean.point.size = c(5, 5, 0)
)
(leave out the mean.point
argument entirely, i. e. neither setting it to TRUE
, FALSE
or any other missingness value)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论