在 {factoextra} PCA biplot 中,仅保留各个群组的平均点。

huangapple go评论74阅读模式
英文:

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)

以下是输出部分:

在 {factoextra} PCA biplot 中,仅保留各个群组的平均点。

英文:

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&lt;-as.factor(iris$Species)
res.pca&lt;-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:

在 {factoextra} PCA biplot 中,仅保留各个群组的平均点。

答案1

得分: 1

你可以为平均点分配不同的大小。在你的示例中,蓝色点是第三组的平均值,所以你可以将大小向量的第三个位置设为零以隐藏该点:

fviz_pca_biplot(## ...其他参数
                ## 但不包括 mean.point
                mean.point.size = c(5, 5, 0)
                )

(完全省略 mean.point 参数,即不将其设置为 TRUEFALSE 或任何其他缺失值)

英文:

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)

huangapple
  • 本文由 发表于 2023年6月12日 02:09:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76451873.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定