首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在r中为簇输出着色

在r中为簇输出着色
EN

Stack Overflow用户
提问于 2013-03-13 21:39:09
回答 1查看 2.1K关注 0票数 1

我有一组集群输出。我想在平行坐标图中用唯一的颜色显示每个簇。我使用rggobi作为平行坐标图。我使用了这个链接http://www.ggobi.org/docs/parallel-coordinates/

下面是我将数据加载到ggobi的代码

代码语言:javascript
复制
library(rggobi)
mydata <- read.table("E:/Thesis/Experiments/R/input.cvs",header = TRUE,sep = ",")
 g <- ggobi(mydata)

这是我的输出

我想用不同的颜色来表示不同的集群。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-13 22:11:31

您还可以使用MASS:parcoord():

代码语言:javascript
复制
require(MASS)
cols = c('red', 'green', 'blue')
parcoord(iris[ ,-5], col = cols[iris$Species])

或者使用ggplot2:

代码语言:javascript
复制
require(ggplot2)
require(reshape2)
iris$ID <- 1:nrow(iris)
iris_m <- melt(iris, id.vars=c('Species', 'ID'))
ggplot(iris_m) + 
  geom_line(aes(x = variable, y = value, group = ID, color = Species))

还请注意this帖子!

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15386960

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档