I have just posted a new version of the phytools function plotSimmap (and a new phytools package version, phytools 0.2-82) that can be compatible with the ape functions nodelabels, edgelabels, and tiplabels. This is accomplished by setting the environmental variable "lastplot.phylo" in the environment .PlotEnvPhylo following the ape convention. This environmental variable is a list containing all the information used by nodelabels and similar to identify the location of nodes in the current plotting window.
This is a little experimental - but let's try it out:
> # ecomorph tree
> plotSimmap(tree,pts=FALSE,lwd=3,fsize=0.7,setEnv=TRUE)
no colors provided. using the following legend:
CG GB TC TG Tr TW
"black" "red" "green3" "blue" "cyan" "magenta"
setEnv=TRUE is experimental. please be patient with bugs
> nodelabels(cex=0.7)
We can also do leftward facing trees:
no colors provided. using the following legend:
CG GB TC TG Tr TW
"black" "red" "green3" "blue" "cyan" "magenta"
setEnv=TRUE is experimental. please be patient with bugs
> nodelabels(cex=0.7)
One handy use of this might be to plot the posterior probabilities of each node as a pie chart on top of one example stochastic map. (I coerced nodelabels into doing that here, but this is much neater.) For example:
> # get the posterior probs from our sample
> PP<-describe.simmap(trees,message=FALSE)$ace
> # let's leave space for a legend
> plot.new(); par(mar=rep(0.1,4))
> par(usr=c(-0.04,1.04,-5,1.04*length(tree$tip.label)))
> # set colors
> cols<-setNames(palette()[1:6],sort(unique(getStates(tree,"tips"))))
> # plot
> plotSimmap(tree,cols,lwd=2,pts=FALSE,add=TRUE,fsize=0.7, setEnv=TRUE)
setEnv=TRUE is experimental. please be patient with bugs
> nodelabels(pie=PP,piecol=palette()[1:6],cex=0.6)
> add.simmap.legend(colors=cols,vertical=FALSE)
Click where you want to draw the legend
That's pretty cool, I think.