简体   繁体   English

树状图的分​​层聚类的不同可视化

[英]Different visualization for hierarchical clustering of dendrogram

I would like to have visualization of hierarchical clustering with shapes one inside the other. 我希望可视化层次聚类的形状,其中一个内部互为形状。 Brightness level represents level of hierarchy. 亮度级别表示层次结构的级别。 Let me show you my idea with an example: 让我通过示例向您展示我的想法:

# Clustering small proportion of iris data   
clusters <- hclust(dist(iris[20:28, 3:4]), method = 'average')
# Visualizing the result as a dendogram    
plot(clusters)

在此处输入图片说明

Now we can convert the dendrogram as below. 现在,我们可以按以下方式转换树状图。 在此处输入图片说明

Is there any R package that can produce something similar? 是否有任何R包可以产生类似的结果?

This is only a partial answer. 这只是部分答案。 You can use clusplot from the cluster package to get some way in that direction. 您可以使用cluster程序包中的clusplot该方向进行操作。 You could probably improve on this by changing the source of clusplot (type getAnywhere(clusplot.default) to get the source). 您可能可以通过更改clusplot的来源(键入getAnywhere(clusplot.default)以获取来源)来对此进行改进。 But it is probably some work to get your bubbles to not overlap. 但是,可能需要做一些工作才能使气泡不重叠。 Anyway, here's the plot you get from clusplot . 无论如何,这是您从clusplot获得的情节。 It may also be of interest to look at the individual plots one at a time instead of showing them all together. 一次查看单个图而不是一起显示它们可能也很有趣。

# use sample data
df <- iris[20:28, 3:4]
# calculate hierarchical clustering
hfit <- hclust(dist(df), method = 'average')
# plot dendogram
plot(hfit)
# use clusplot at all possible cutoffs and show on top of each other.
library(cluster)
clusplot(df, cutree(hfit, 1), lines = 0)
for (i in 2:nrow(df)){
  clusplot(df, cutree(hfit, i), lines = 0, add = TRUE)
}

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM