# cophyloplot

##### Plots two phylogenetic trees face to face with links between the tips.

This function plots two trees face to face with the links if specified. It is possible to rotate the branches of each tree around the nodes by clicking.

- Keywords
- hplot

##### Usage

```
cophyloplot(x, y, assoc = NULL, use.edge.length = FALSE, space = 0,
length.line = 1, gap = 2, type = "phylogram", rotate = FALSE,
col = par("fg"), lwd = par("lwd"), lty = par("lty"),
show.tip.label = TRUE, font = 3, ...)
```

##### Details

The aim of this function is to plot simultaneously two phylogenetic trees with associated taxa. The two trees do not necessarily have the same number of tips and more than one tip in one phylogeny can be associated with a tip in the other.

The association matrix used to draw the links has to be a matrix with two columns containing the names of the tips. One line in the matrix represents one link on the plot. The first column of the matrix has to contain tip labels of the first tree (`phy1`

) and the second column of the matrix, tip labels of the second tree (`phy2`

). There is no limit (low or high) for the number of lines in the matrix. A matrix with two colums and one line will give a plot with one link.

Arguments `gap`

, `length.line`

and `space`

have to be changed to get a nice plot of the two phylogenies. Note that the function takes into account the length of the character strings corresponding to the names at the tips, so that the lines do not overwrite those names.

The `rotate`

argument can be used to transform both phylogenies in order to get the more readable plot (typically by decreasing the number of crossing lines). This can be done by clicking on the nodes. The escape button or right click take back to the console.

##### See Also

##### Examples

```
#two random trees
tree1<-rtree(40) #random tree with 40 leaves
tree2<-rtree(20) #random tree with 20 leaves
#creation of the association matrix
association<-matrix(ncol=2, nrow=40)
association[,1]<-association[,2]<-tree2$tip.label
#plot
cophyloplot(tree1, tree2, assoc=association, length.line=4, space=28, gap=3)
#plot with rotations
cophyloplot(tree1, tree2, assoc=association, length.line=4, space=28, gap=3, rotate=TRUE)
```

*Documentation reproduced from package ape, version 3.0-2, License: GPL (>= 2)*

### Community examples

**lskatz@gmail.com**at Apr 25, 2019 ape v5.3

## quick example ``` tree1 <- reorder(midpoint.root(read.tree(treefile1)), order = "cladewise") tree2 <- reorder(midpoint.root(read.tree(treefile2)), order = "cladewise") association <- cbind(tree1$tip.label, tree1$tip.label) cophyloplot(tree1, tree2, assoc = association, space = 28, length.line=4, gap=3) ```