【问题标题】:color the cluster output in r为 r 中的集群输出着色
【发布时间】:2014-01-13 17:57:55
【问题描述】:

我有一组集群输出。我想在平行坐标图中以独特的颜色显示每个集群。我正在使用 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)

这是我的输出

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

【问题讨论】:

  • 请包含可重现的代码!

标签: r data-visualization


【解决方案1】:

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

另请注意this 发帖!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-15
    • 2011-01-20
    • 1970-01-01
    • 1970-01-01
    • 2020-03-15
    • 2012-09-02
    相关资源
    最近更新 更多