2013-03-13 49 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後!