A little while ago, I updated plotSimmap(...,type="phylogram") to (optionally) set the environmental variable "last_plot.phylo" in the environment .PlotEnvPhylo. This has the effect of making plotSimmap fully compatible with nodelabels, tiplabels, edgelabels, and (now) add.scale.bar from the ape package.
The latest version of plotSimmap includes two important updates: (1) now setting the environmental variable "last_plot.phylo", though still optional, defaults to setEnv=TRUE; and (2) setEnv works for both type="phylogram" and type="fan". Since the latter is new - let's try a quick demo showing a stochastic of 'ecomorph' on the tree of Caribbean Anolis ecomorph species, with posterior probabilities from stochastic mapping at internal nodes overlain:
Loading required package: phytools
> # load anole 'ecomorph' tree
> # this is a stochastic mapped tree - pull tip states
> # conduct stochastic mapping
> trees<-make.simmap(anoletree,x,model="ER",nsim=100, message=FALSE)
> # get the states at ancestral nodes
100 trees with a mapped discrete character with states:
CG, GB, TC, TG, Tr, Tw
trees have 25.79 changes between states on average
changes are of the following types:
> # set colors to be used for mapping
> # plotSimmap
setEnv=TRUE for this type is experimental. please be patient with bugs
> # add node labels
> # add legend
Click where you want to draw the legend
This update is in a new phytools build (phytools 0.3-38).
I try to run this analysis, however the program throws me the following error: Error in make.simmap (tree, states, nsim = 1000, message = FALSE):
subscript out of bounds.
If you could guide me to solve this problem I would be very grateful
P. D. a small query, the species may have been more of a character state?