从群集图中删除点(factoextra)

时间:2018-04-20 07:01:08

标签: r plot cluster-analysis

有没有办法从factoextra包的fviz_cluster函数中删除点(绘制factominer的包)。

enter image description here

正如你所看到的,这点有点乱,我想只保留聚类中心和椭圆体。

fviz_cluster(HCPC9CL, repel = FALSE, geom = "point", show.clust.cent = TRUE, ellipse.type = "norm", palette = trololo, ggtheme = theme_minimal(), main = "Factor map")

1 个答案:

答案 0 :(得分:2)

也许最简单的解决方案是设置alpha = 0

以下是一个例子:

set.seed(123)
data(iris)
iris.scaled <- scale(iris[, -5])
km.res <- kmeans(iris.scaled, 3, nstart = 10)


fviz_cluster(km.res, iris[, -5],
             repel = FALSE,
             geom = "point",
             show.clust.cent = TRUE,
             ellipse.type = "norm",
             ggtheme = theme_minimal(),
             main = "Factor map",
             alpha = 0)

enter image description here

但是我建议不要删除这些点,而是要使它们透明,并且只使用颜色来区分它们:

fviz_cluster(km.res, iris[, -5],
             repel = FALSE,
             geom = "point",
             show.clust.cent = TRUE,
             ellipse.type = "norm",
             ggtheme = theme_minimal(),
             main = "Factor map",
             alpha = 0.2,
             shape = 19)

enter image description here