2013-03-13 48 views
1

我有一组集群输出。我想在平行坐标图中以独特的颜色显示每个群集。我正在使用rggobi来绘制平行坐标图。我用这个链接 http://www.ggobi.org/docs/parallel-coordinates/颜色集群输出在r

这里是我的代码加载数据ggobi

library(rggobi) 
mydata <- read.table("E:/Thesis/Experiments/R/input.cvs",header = TRUE,sep = ",") 
g <- ggobi(mydata) 

这里是我的输出 parallel coordinate

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

+1

请包含可复制的代码! – 2013-03-13 13:49:02

回答

4

你也可以使用MASS ::: parcoord():

require(MASS) 
cols = c('red', 'green', 'blue') 
parcoord(iris[ ,-5], col = cols[iris$Species]) 

或者与GGPLOT2:

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)) 

enter image description here

另外请注意this后!