R中树状图中的标签

时间:2015-09-22 14:51:24

标签: r labels dendrogram dendextend

我正在研究树状图

plot(clust.res, hang=-1, main=dedro,labels=data1$Name.of.the.variety)

然后我收到的消息是:

Warning messages:
"labels" is not a graphical parameter

1 个答案:

答案 0 :(得分:1)

这是有道理的。 通常,plot.dendrogram函数没有labels参数,并且不允许您修改它绘制的树形图的标签。

但是,可以使用the dendextend R package

以下是一个简单的例子:

# 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包还允许您修改标签颜色和大小see here for examples

enter image description here