Monday, July 14, 2014

New user controls in

I just posted a version of the phytools function, which can be used to project a tree onto a geographic map. Based on some user feedback, including at the Latin American Macroevolutionary Workshop we just held at the Universidad de los Andes in Bogotá, Colombia, I have added a couple of new features & attributes to the function.

First, the function now automatically removes the underscore character ("_") from within species names. Note that this is only for type="phylogram", not type="direct"; although in the latter case it can easily be done manually.

Second, again for type="phylogram", the lines connecting the tree to locations on a geographic map now (by default) arise from the end of the tip label - rather than from the tip itself.

Finally, third, the function now allows user control of the color of both the dashed lines & points connecting species labels to their geographic locations (for type="phylogram"); and of the both the lines and tip dot colors (for type="direct".

These updates are in the latest non-CRAN phytools build. Here's a quick demo:

> packageVersion("phytools") [1] ‘0.4.24’
> ## simulate some realistic looking data
> foo<-function() paste(c(sample(LETTERS,1),
> tree<-pbtree(n=40,tip.label=replicate(40,foo()))
> tree$edge.length<-tree$edge.length*
> lat<-fastBM(tree,sig2=10,bounds=c(-90,90))
> long<-fastBM(tree,sig2=20,bounds=c(-180,180))
> X<-cbind(lat,long)
> ## ok, first the (new) standard plot:
> obj<,X,ftype="i",fsize=0.7,
objective: 302
objective: 220
objective: 218
objective: 218
> ## now let's change the colors:
> plot(obj,colors=c("blue","red"),ftype="i",fsize=0.7,
> ## direct projection with different colors
> plot(obj,type="direct",colors=c("red","black"),
That's it.


  1. Dear Liam,

    Is there any way to use this function on a smaller scale, say plotting the phylogeny against a smalle map of a single continent/country?

    Kind regards,


    1. Yes. Try the arguments database and regions. - Liam

    2. You can also set xlim and ylim based on geographic coordinates.

  2. Dear Liam,

    Do you have an example where points can be coloured by a vector of colours? I have tried just inputting that vector and list("black", col_vector) under the argument color, but no luck yet.


Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.