Labels in dendrogram in R
我正在研究树状图
1 | plot(clust.res, hang=-1, main=dedro,labels=data1$Name.of.the.variety) |
然后我得到的消息是:
1 2 | Warning messages: "labels" is not a graphical parameter |
这是有道理的。
通常,
但是,可以使用dendextend R 包来实现。
这里有一个简单的例子供你参考:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # some data and create the dendrogram DATA <- 1:4 hc <- hclust(dist(DATA)) dend <- as.dendrogram(hc) # Get dendextend for editing the labels if(!require(dendextend)) install.packages("dendextend") library(dendextend) # Copy the object, and edit its labels dend2 <- dend labels(dend2) <- c("one","two","3","four") # compare the two dendrograms: par(mfrow = c(1,2)) plot(dend, main ="original dend") plot(dend2, main ="dend with edited labels") |
dendextend 包还允许您修改标签的颜色和大小,请参见此处的示例。