簡體   English   中英

為r中的群集輸出着色

[英]color the cluster output in r

我有一組集群輸出。 我想在平行坐標圖中顯示每個具有獨特顏色的簇。 我使用rggobi作為平行坐標圖。 我用這個鏈接http://www.ggobi.org/docs/parallel-coordinates/

這是我的代碼將數據加載到ggobi

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

這是我的輸出 平行坐標

我想用不同的顏色來表示不同的簇。

你也可以使用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))

在此輸入圖像描述

請注意這篇文章!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM