R 如何删除树状图上的标签?
R How to remove labels on dendrogram?
我怎样才能删除这个情节的所有标签?或者,也许更好,我怎样才能让它变得可读?
我用这个命令创建了它:
plot(hclust(distance), main="Dissimilarity = 1 - Correlation", xlab= NA, sub=NA)
我读了很多遍,实际上 xlab
或 sub
应该删除标签,但它对我不起作用!
我的剧情是这样的:
可以设置labels=FALSE
distance = as.dist(1 - cor(mtcars))
plot(hclust(distance), main="Dissimilarity = 1 - Correlation", labels=FALSE)
如果您想更改标签的大小并使它们易于阅读,您可以使用 dendextend 包。在这里查看一些非常好的信息: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).
具体来说:
labels_cex - set the labels’ size (using assign_values_to_leaves_nodePar)
还有更多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
别忘了添加库:
# install.packages("dendextend")
library(dendextend)
我怎样才能删除这个情节的所有标签?或者,也许更好,我怎样才能让它变得可读?
我用这个命令创建了它:
plot(hclust(distance), main="Dissimilarity = 1 - Correlation", xlab= NA, sub=NA)
我读了很多遍,实际上 xlab
或 sub
应该删除标签,但它对我不起作用!
我的剧情是这样的:
可以设置labels=FALSE
distance = as.dist(1 - cor(mtcars))
plot(hclust(distance), main="Dissimilarity = 1 - Correlation", labels=FALSE)
如果您想更改标签的大小并使它们易于阅读,您可以使用 dendextend 包。在这里查看一些非常好的信息: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).
具体来说:
labels_cex - set the labels’ size (using assign_values_to_leaves_nodePar)
还有更多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
别忘了添加库:
# install.packages("dendextend") library(dendextend)