简体   繁体   中英

How to reduce leaves length for fitting labels in R dendrogram?

I produced a cluster with hcluster . original dendogram .

For formatting purposes I used as.dendogram . When I did that my labels were cut of. vertical dendogram

Even more by the horizontal orientation. The one I need. horizontal dendogram

The problem does not seams to be in margins since (for the horizontal one) I used par(oma = c(0, 0, 0, 8) with not label effect. It only a reduced my margins but not give more room for labels names. How can I make sure that the plot shows the entire model names?

You should probably change mar and not oma in par() :

mm <- matrix(rnorm(20), ncol = 4)
colnames(mm) <- c("leaf1", "leaf2", "leaf3", "very_long_leaf_realy")

# compare:
plot(as.dendrogram(hclust(dist(t(mm)))), horiz = TRUE)

# with:
oldpar <- par(mar = c(5, 4 ,4 , 8))
plot(as.dendrogram(hclust(dist(t(mm)))), horiz = TRUE)
par(oldpar) # restoring ploting parameters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM