Friday, April 13, 2018

Some small update to control tip label linking lines in plot.cophylo

On user request I today pushed a very small update to allow the lengths of the linking lines connecting the tips of the tree to the tip labels in a plotted "cophylo" to be controlled by the user.

First, a quick reminder of how a plotted object would normally look:

library(phytools)
t1
## 
## Phylogenetic tree with 20 tips and 19 internal nodes.
## 
## Tip labels:
##  t7, t8, t5, t6, t2, t3, ...
## 
## Rooted; includes branch lengths.
t2
## 
## Phylogenetic tree with 25 tips and 24 internal nodes.
## 
## Tip labels:
##  t1, t12, t13, t5, t6, t20, ...
## 
## Rooted; includes branch lengths.
obj<-cophylo(t1,t2)
## Rotating nodes to optimize matching...
## Done.
plot(obj,link.type="curved")

plot of chunk unnamed-chunk-1

The argument to shorten the linking lines is tip.len, but we can also combine it with tip.lty to turn of the tip lines entirely:

plot(obj,tip.lty=0,tip.len=0.01,pts=FALSE,part=0.35)

plot of chunk unnamed-chunk-2

Finally, let's say we want to turn off the tip labels and draw our linking lines directly from the tips (the tiplabels.cophylo I added just for fun):

plot(obj,tip.len=0,ftype="off",part=0.35,lwd=2)
tiplabels.cophylo(pie=to.matrix(rep(1,Ntip(obj$trees[[1]])),"1"),
    cex=0.3,piecol="grey")
tiplabels.cophylo(pie=to.matrix(rep(1,Ntip(obj$trees[[2]])),"1"),
    cex=0.3,piecol="grey",which="right")

plot of chunk unnamed-chunk-3

That's it.

No comments:

Post a Comment

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.