我在R中有一个树状图,我只能做对了。
我会告诉您问题所在,请查看:http://img.photobucket.com/albums/v699/rica01/Rplot-1.png
如何在树叶上制作标签,更大,间距更大?
感谢。
-Ricardo
答案 0 :(得分:3)
解决方案:使用set
函数以及dendextend包中的“labels_cex”参数。
# install.packages("dendextend")
library(dendextend)
dend <- as.dendrogram(hclust(dist(USArrests[1:5,])))
# Like:
# dend <- USArrests[1:5,] %>% dist %>% hclust %>% as.dendrogram
# By default, the dend has no text size to it (showing only the first leaf)
get_leaves_nodePar(dend)[[1]]
par(mfrow = c(1,2), mar = c(10,4,4,2))
plot(dend, main = "Original dend")
# let's increase the size of the labels:
dend <- set(dend, "labels_cex", 2)
# Now each state has a larger label
get_leaves_nodePar(dend)[[1]]
plot(dend, main = "A larger font for labels")
(请注意,目前尚未实现更改标签之间的间距)
有关该软件包的更多详细信息,您可以查看at its vignette。