Friday, May 24, 2013

Creating a type="fan" densityMap or contMap plot

I have not yet added the "type" argument to functions densityMap or contMap; however it is already possible to create a circular densityMap or contMap style tree. Here's how:

> require(phytools)
Loading required package: phytools
> packageVersion("phytools")
[1] ‘0.2.71’
> # simulate tree & data
> tree<-pbtree(n=100,scale=1)
> x<-fastBM(tree)
> # first plot typical contMap & obtain "contMap" object
> XX<-contMap(tree,x) # we don't care about this one
> # now plot with type="fan"
> plotSimmap(XX$tree,XX$cols,type="fan")
Note: type='fan' is in development. Most options not yet available.
> # finally, add color bar
> # (we have to click where we want this)
> add.color.bar(0.8,cols=XX$cols,title="trait value", lims=range(x),digits=2)

Note that we have to click where we want to put the color bar/legend.

That's it.

2 comments:

  1. thanks Liam! Worked beautifully. There is some aliasing which I guess is inevitable since it's basically plotting a bunch of little squares, right? Thanks again, looks gorgeous - and is exactly what I needed! http://d.pr/i/WALi

    ReplyDelete
    Replies
    1. Nope - this is just R when you export as a raster graphic. See the difference between a .png exported directly from R and a .jpg created by exporting in vector format & then converting to .jpg in Illustrator here.

      Delete