0

我想在树状图底部为树状图的节点着色-但在单独的行中下面链接中的最后一个树状图将节点显示为彩色-但是当它是一个大数据集时,一行变得非常脏 标签和r中的彩色叶子树状图 那么每个彩色组是否可以有单独的行?

4

1 回答 1

0

Yes. You want to use the function colored_bars from the dendextend package. Please see the following example (from the dendextend vignette)

library(dendextend)
dend15 <- c(1:5) %>% dist %>% hclust(method = "average") %>% as.dendrogram
is_odd <- ifelse(labels(dend15) %% 2, 2,3)
is_345 <- ifelse(labels(dend15) > 2, 3,4)
is_12 <- ifelse(labels(dend15) <= 2, 3,4)
k_3 <- cutree(dend15,k = 3, order_clusters_as_data = FALSE) 
# The FALSE above makes sure we get the clusters in the order of the
# dendrogram, and not in that of the original data. It is like:
# cutree(dend15, k = 3)[order.dendrogram(dend15)]
the_bars <- cbind(is_odd, is_345, is_12, k_3)
the_bars[the_bars==2] <- 8

dend15 %>% plot
colored_bars(colors = the_bars, dend = dend15)

enter image description here

于 2016-12-24T10:28:42.187 回答