Thursday, October 27, 2016

Plotting multiple pie charts at nodes

An R-sig-phylo question asked:

“I have made an ancestral state reconstruction for three discrete traits using the R package "phytools”,and I don't know how to draw the three asr pies on the node in a single plot.“

Although this can get messy, it is possible to do this using the argument adj. For instance:

library(phytools)
plotTree(tree)
nodelabels(pie=p1,adj=c(0.5,0.9),cex=0.5)
nodelabels(pie=p2,adj=c(0.5,0.5),cex=0.5)
nodelabels(pie=p3,adj=c(0.5,0.1),cex=0.5)

plot of chunk unnamed-chunk-1

to arrange vertically. To arrange horizontally, do:

plotTree(tree)
nodelabels(pie=p1,adj=c(0.445,0.5),cex=0.5)
nodelabels(pie=p2,adj=c(0.5,0.5),cex=0.5)
nodelabels(pie=p3,adj=c(0.555,0.5),cex=0.5)

plot of chunk unnamed-chunk-2

The specific values for adj will depend on the scale of the tree & the number of tips.

1 comment:

  1. To visualize the results, I use mind maps, or a powerpoint presentation. PowerPoint https://www.templatemonster.com/ru/powerpoint-templates-type/ It's good to use when you need to present data at a conference or another presentation. Using ready-made templates for making scientific reports helps to make a report better and improves the perception of information

    ReplyDelete