emmanuelparadis / ape

analysis of phylogenetics and evolution
http://ape-package.ird.fr/
GNU General Public License v2.0
53 stars 11 forks source link

fix problems with x.lim and y.lim #119

Closed KlausVigo closed 4 months ago

KlausVigo commented 4 months ago

Hi @emmanuelparadis and @liamrevell,
some bug fixes to plot.phylo. When supplying x.lim or x.lim there was a bug for downwards and leftwards.

The changes allows to arrange plots from ape, phangorn & phytools nicely next to each other! This now makes also figure 5 in the phangorn manuscript much nicer. At Liam: plotTree has a side effect and changes the outer margin.

Cheers, Klaus

And here is the code to show the problem:

library(ape)
library(phangorn)
library(phytools)

set.seed(42)
tree <- rcoal(5)
tree$edge.length <- tree$edge.length / max(node.depth.edgelength(tree))
trees <- c(tree, tree)

par(mfrow=c(3,1)) 
direction="rightwards"
plotTree(tree, direction=direction, xlim=c(-.5,2))
abline(v=c(-.5,0,1,2))
plot(tree, direction=direction, x.lim=c(-.5,2))
abline(v=c(-.5,0,1,2))
densiTree(trees, direction=direction, xlim=c(-.5,2))
abline(v=c(-.5,0,1,2))
direction="leftwards"
plot(tree, direction=direction, x.lim=c(-.5,2))
abline(v=c(-.5,0,1,2))
plotTree(tree, direction=direction, xlim=c(-.5,2))
abline(v=c(-.5,0,1,2))
densiTree(trees, direction=direction, xlim=c(-.5,2))
abline(v=c(-.5,0,1,2))
par(mfrow=c(1,3)) 
direction="downwards"
plotTree(tree, direction=direction, ylim=c(-.5,2))
abline(h=c(-.5,0,1,2))
plot(tree, direction=direction, y.lim=c(-.5,2))
abline(h=c(-.5,0,1,2))
densiTree(trees, direction=direction, ylim=c(-.5,2))
abline(h=c(-.5,0,1,2))
direction="upwards"
plotTree(tree, direction=direction, ylim=c(-.5,2))
abline(h=c(-.5,0,1,2))
plot(tree, direction=direction, y.lim=c(-.5,2))
abline(h=c(-.5,0,1,2))
densiTree(trees, direction=direction, ylim=c(-.5,2))
abline(h=c(-.5,0,1,2))
emmanuelparadis commented 4 months ago

Hi @KlausVigo, Merged. Thanks! E.