Hi Darren,
On Tue, 28 Sep 2010 15:07:54 +0100
Darren Obbard <darren.obb...@ed.ac.uk> wrote:
Hi,
I wish to achieve a plot that looks like the one linked from the APE
homepage
http://ape.mpl.ird.fr/image/Figure2_TEJEDO.png
Does anyone have code that will do this, or could provide me with
some good ideas as to how I make the bar centres of barplot() line up
with the tip labels.
Taking some random data:
tr <- rcoal(30)
x <- rnorm(30)
Here's an example on how to do it:
plot(tr, x.lim = 5) # <- adjust x.lim
offset <- 4 # <- adjust offset
barplot(c(NA, x), add = TRUE, horiz = TRUE, space = 0, offset =
offset, axes = FALSE)
lab <- pretty(x)
axis(1, lab + offset, labels = lab)
The trick is to add NA to the x vector to lift the barplot by one
unit. This requires to adjust manually two parameters: x.lim and
offset. You may also adjust 'lab' and/or rescale x to make it look
nicer.
If you want to check that all is lined up:
abline(h=1:30, col = "red", lty = 3)
HTH
Emmanuel
Thanks,
Darren
--
Darren Obbard
Institute of Evolutionary Biology
University of Edinburgh, UK
darren.obb...@ed.ac.uk
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo