我的树形图非常丑陋,处于难以理解的边缘,通常看起来像这样:
library(TraMineR)
library(cluster)
data(biofam)
lab <- c("P","L","M","LM","C","LC","LMC","D")
biofam.seq <- seqdef(biofam[1:500,10:25], states=lab)
ccost <- seqsubm(biofam.seq, method = "CONSTANT", cval = 2, with.missing=TRUE)
sequences.OM <- seqdist(biofam.seq, method = "OM", norm= TRUE, sm = ccost,
with.missing=TRUE)
clusterward <- agnes(sequences.OM, diss = TRUE, method = "ward")
plot(clusterward, which.plots = 2)
我想要创建的内容类似于以下内容,这意味着圆形树状图,可以仔细控制标签的大小,使它们实际可见:
我如何在R?
中完成此任务答案 0 :(得分:9)
以下解决方案可能不是最佳解决方案,但值得一试:
library(ape)
CL1 <- as.hclust(clusterward)
CL2 <- as.phylo(CL1)
plot(CL2, type="fan", cex=0.5)
主要问题显然是对象太多,因此标签太多。要关闭标签,请使用参数show.tip.label=FALSE
。您还可以使用no.margin=TRUE
plot(CL2, type="fan", show.tip.label=FALSE, no.margin=TRUE)