## load tree and data from Revell & Collar (2009)
data(sunfish.tree)
data(sunfish.data)
## extract discrete character (feeding mode)
fmode<-setNames(sunfish.data$feeding.mode,
rownames(sunfish.data))
## fit discrete character models
sunfish_er<-fitMk(sunfish.tree,fmode,model="ER")
## do stochastic mapping
smap.trees<-simmap(sunfish_er)
## compute "densityMap" object
sunfish.dmap<-densityMap(smap.trees,plot=FALSE,
res=100)
## re-color
sunfish.dmap<-setMap(sunfish.dmap,hcl.colors(n=10))
## plot density map
plot(sunfish.dmap,lwd=5,outline=TRUE)
## reset margins to default
par(mar=c(5.1,4.1,4.1,2.1))
Run the code above in your browser using DataLab