Learn R Programming

phytools (version 1.0-3)

add.arrow: Add an arrow pointing to a tip or node on the tree

Description

This function adds an arrow or a set of arrows to a plotted tree.

Usage

add.arrow(tree=NULL, tip, ...)

Arguments

tree

an object of class "phylo", "contMap", or "densityMap". If not supplied, the function will obtain the last plotted phylogeny from the environmental variable last_plot.phylo.

tip

label of tip or tip or node number; or vector of such values. If tree=NULL then the tip label(s) or node number(s) must be supplied.

...

optional arguments to control the shape and size of the arrow including: its length (arrl) in the units of the plot; the length of the arrowhead (hedl); the total angle between the wings in the arrowhead (angle); the line width for the plotted lines (lwd); the offset from the tip or end of tip label, in character widths (offset); and the color (col).

Author

Liam Revell liam.revell@umb.edu

Details

This function presently works for radial (type="fan") and right facing square phylograms (type= "phylogram"). Trees can be plotted using phytools function plotTree, plotSimmap, contMap, densityMap, and ape S3 method plot.phylo.

References

Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223.

See Also

nodelabels

Examples

Run this code
## show arrows with a black outline
data(anoletree)
plotTree(anoletree,type="fan",fsize=0.7,ftype="i")
add.arrow(anoletree,tip=c("cuvieri","krugi",
    "pulchellus","poncensis","stratulus",
    "evermanni","cooki","cristatellus",
    "gundlachi","occultus"),lwd=5,arrl=1)
add.arrow(anoletree,tip="cuvieri",col="green",
    lwd=3,arrl=1)
add.arrow(anoletree,tip=c("krugi","pulchellus",
    "poncensis"),col="#E4D96F",lwd=3,arrl=1)
add.arrow(anoletree,tip=c("stratulus","evermanni"),
    col="darkgreen",lwd=3,arrl=1)
add.arrow(anoletree,tip=c("cooki","cristatellus",
    "gundlachi"),col="brown",lwd=3,arrl=1)
add.arrow(anoletree,tip="occultus",col="darkgrey",
    lwd=3,arrl=1)
legend(x="topleft",c("crown-giant","grass-bush","trunk-crown","trunk-ground",
    "twig"),pch=22,pt.bg=c("green","#E4D96F","darkgreen",
    "brown","darkgrey"),cex=0.9,
    pt.cex=2,title="PR ecomorphs",bty="n")
par(mar=c(5.1,4.1,4.1,2.1)) ## reset margins to default

Run the code above in your browser using DataLab