Larger font and gap between leaves in R dendrogram

I have a dendrogram in R, I just can't figure it out.

I will show you what the problem is, please check this: http://img.photobucket.com/albums/v699/rica01/Rplot-1.png

How can I make labels on sheets more and more in between?

Thanks.

-Ricardo

+5
source share
1 answer

Solution: use the set function with the "labels_cex" parameter from the dendextend package.

 # 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 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") 

enter image description here

(note that changing the spacing between labels is not currently implemented)

For more information about the package, you can look at your vignette .

+3
source

Source: https://habr.com/ru/post/1206998/


All Articles