PCA 改变簇的颜色 [英] PCA change colours of clusters

查看:69
本文介绍了PCA 改变簇的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变集群的颜色但保持形状.habillage=iris$Species 改变颜色和形状,什么可以只改变颜色?

I want to change the colours of my clusters but maintain the shape. habillage=iris$Species changes both colour and shape, what can to change only colours?

library("devtools")
install_github("kassambara/factoextra")
library("factoextra")
res.pca <- prcomp(iris[, -5],  scale = TRUE)
fviz_pca_ind(iris.pca,  geom="point",  pointsize = 1, habillage=iris$Species, addEllipses=TRUE, ellipse.level=0.95)

推荐答案

fviz_pca() 的工作方式类似于 ggplot 图,因此,要更改形状,您可以使用 ggplot 的美学映射,例如,用于更改形状.关于颜色,?fviz_pca_ind 调用的文档告诉您可以通过palette 更改颜色.

fviz_pca() works like ggplot plots, hence, for changing shapes you can use the aesthetic mappings of ggplot, e.g., for changing shapes. Concerning colors, the documentation called by ?fviz_pca_ind tells you that you can change colors via palette.

fviz_pca_ind(res.pca,  geom="point",  pointsize = 1, habillage=iris$Species, addEllipses=TRUE, ellipse.level=0.95
             , palette = c("green", "orange", "grey") #change colors
             ) + 
             scale_shape_manual(values=c(2, 8, 11)) #change shapes

这篇关于PCA 改变簇的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆