2014-01-28 55 views
5

我的树状图是可怕的丑,对不可读的边缘,通常是这样的:R的漂亮树状图?

enter image description here

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) 

我想什么来创建是类似于以下,这意味着一轮树状图,其中标签的尺寸进行仔细的控制,使他们实际上是可见:

enter image description here

我如何R中做到这一点?

+0

为什么会有人downvote这个问题,我是无法理解。 –

+0

@RichardScriven - 你怎么看到它被低估?我只能看到总票数。 – histelheim

+0

我认为这个特权带有1k的声望。 –

回答

8

以下解决方案可能不是最优的,但值得一试:

library(ape) 
CL1 <- as.hclust(clusterward) 
CL2 <- as.phylo(CL1) 
plot(CL2, type="fan", cex=0.5) 

enter image description here

的主要问题显然是,仍然有太多的对象,因此太多的标签的事实。要关闭标签,请使用参数show.tip.label=FALSE。您也可以摆脱利润率占据整个设备与no.margin=TRUE

plot(CL2, type="fan", show.tip.label=FALSE, no.margin=TRUE) 

enter image description here

+0

你也可以关掉标签吗?考虑到重叠,它们不会向情节添加太多信息。 – histelheim

+2

@histelheim是,参数为'show.tip.label = FALSE'。 – plannapus

+0

这可能超出范围,但有没有简单的方法来切割树?我已经尝试了'cutree'以及as.hclust'的'members'参数,但似乎无法使其工作。 – histelheim