【发布时间】:2020-06-20 01:28:37
【问题描述】:
我在生成聚类树状图时遇到了一点问题。
集群技术正在发挥作用,问题只是图表。我想对它做些小调整。
X 轴上的名称与群组划分的线条末端之间的距离很大,并且不必要地覆盖了图表的大部分,我非常想减少它(图像上的绿色标记)。因此,我希望 Y 轴上的刻度增加(图像上的蓝色标记)。
有人知道如何解决这个问题吗?我搜索了 rect.hclust 的文档,但没有发现进行这些调整的参数。
为了便于理解,我附上了生成的树状图的脚本和图像以及我希望发生的事情。
非常感谢您的关注(和帮助)!
pts <- read_excel("C:/pts.xlsx")
row.names(pts) <- c("Painting","Dance","Photo", "Cinema","Book","Music")
matrix = dist(pts, "euclidean")
group = hclust(matrix, "ward.D")
hcd <- as.dendrogram(group)
dend_data <- dendro_data(hcd, type = "rectangle")
plot(group, hang=-1)
rect.hclust(group, k=3, border="red")
【问题讨论】:
-
情节(组,挂=-1); rect.hclust(group, k=3, border="red") 是正确的,您只需要调整绘图设备的大小,或者将其保存为 png
标签: r plot hierarchical-clustering dendrogram