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. Every time you stop outside that glass window showing those glittering, stunning Rolex

    watches. This is a heartfelt desire to wrap your wrist with this most well- known name,Svizzeri perfetti Orologi. There is good news

    for you. Now, you need not to spend those big bucks for acquiring your dream watch. Your

    answer is Replica watches. Yes come here buySvizzeri Repliche Orologi

    ReplyDelete