ggtree
ggtree copied to clipboard
ggdensitree + revts
trafficstars
I would like to make a plot as hinted here: https://github.com/YuLab-SMU/ggtree/issues/87 e.g. a densitree with a timescale with 0 at the tips, and -crown_age at the root.
However, the following code does not work as expected, and only reverts one of the two tree plots.
trees <- list()
trees[[1]] <- rtree(n = 10)
trees[[2]] <- rtree(n = 10)
class(trees) <- "multiPhylo"
p <- ggdensitree(trees) + theme_tree2()
p2 <- revts(p)
multiplot(p, p2, ncol=2)
I have built a workaround for this in 5a70208dbea02567bd11eec7fe2e99ef369b3ef9. ggdensitree will set the maximum tip date to 0 when align.tips = TRUE (the default). So,
trees <- list()
trees[[1]] <- rtree(n = 10)
trees[[2]] <- rtree(n = 10)
class(trees) <- "multiPhylo"
p <- ggdensitree(trees) + theme_tree2()
p
will produce the plot you want, with no revts required.

Works like a charm! Also, works for all densitrees