我正在使用此鏈接根據類別繪製帶有彩色標籤的樹狀圖。 第二個答案是什麼,我在使用下面的代碼此鏈接(Tree cut and Rectangles around clusters for a horizontal dendrogram in R)看:我要切出一些簇的,因爲我有16個簇,與145個標籤,這樣 d <- dist(t(mat[,3:ncol(mat)]), method = "euclid
Didzis Elferts展示瞭如何使用GGPLOT2和ggdendro繪製一個樹狀圖: horizontal dendrogram in R with labels 這裏是代碼: labs = paste("sta_",1:50,sep="") #new labels
rownames(USArrests)<-labs #set new row names
hc <- hclust(dis