how can I remove all that lables of this plot? Or, maybe even better, how could I make it readable?
I created it with this command:
plot(hclust(distance), main="Dissimilarity = 1 - Correlation", xlab= NA, sub=NA)
I read multiple times, that actually xlab
or sub
should remove the labels, but it doesn't work for me!
My plot looks like this:
You can set labels=FALSE
distance = as.dist(1 - cor(mtcars))
plot(hclust(distance), main="Dissimilarity = 1 - Correlation", labels=FALSE)
If you wish to change the size of the labels and make them readible you can use the dendextend package. See here for some really good info: Introduction to dendextend
Introduction to dendextend
The dendextend package offers a set of functions for extending dendrogram objects in R, letting you visualize and compare trees of hierarchical clusterings, you can:
- Adjust a tree’s graphical parameters - the color, size, type, etc of its branches, nodes and labels.
- Visually and statistically compare different dendrograms to one another.
The goal of this document is to introduce you to the basic functions that dendextend provides, and show how they may be applied. We will make extensive use of “chaining” (explained next).
Specifically:
labels_cex - set the labels’ size (using assign_values_to_leaves_nodePar)
And more specifically:
We can get a vector with the tree’s labels:
# get the labels: dend15 %>% labels
We may also change their color and size:
par(mfrow = c(1,2)) dend15 %>% set("labels_col", "blue") %>% plot(main = "Change label's color") # change color dend15 %>% set("labels_cex", 2) %>% plot(main = "Change label's size") # change size
Dont forget to add the library:
# install.packages("dendextend") library(dendextend)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With