A recent R-sig-phylo query asked the following about phytools function phylomorphospace3d (for projecting a tree into a three-dimensional morphospace):
"[Is t]here is a possbility to color some specific edges in the phylomorphospace3d()? plot.phylo() has the argument "edge.color" to do that in classical tree plotting. I need it, however, in the above mentioned function."
This functionality (as well as the ability to plot a stochastic character map on a phylomorphospace) exists for two-dimensional phylomorphospace plotting, but it did not (until now) exist for phylomorphospace3d; however, this was not too difficult to add. I have added user control of plotted line colors via the control parameter col.edge (as in phylomorphospace), rather than via a new function argument.
Code for this new function version is here; but users may prefer to install the latest bleeding edge source version of phytools (phytools 0.4-14) to ensure that everything works as advertised.
Here is a demo that plots the internal edges of a 3D phylomorphospace in blue, while the terminal edges are plotted in red:
packageVersion("phytools") ## should be >=0.4-14
## simulate tree
## create color vector
colors<-sapply(tree$edge[,2], function(x,n) if(x>n) "blue"
## generate 3D phylomorphospace plot
BTW, to create this cool .gif, you just need to do something like:
The same option is also available for method="static", e.g.:
I should have mentioned that to create an animated .gif using movie3d you need to first install ImageMagick. - LiamReplyDelete
I can not figure out how to change color of tips...
I tried this:
col.edge <- sapply(simmap.tree$mapped.edge[,2], function (x) if (x>0) "red"
phylomorphospace3d (simmap.tree, X = data[,1:3], control = list (ftype = "off", box = F, col.edge = col.edge), color = col.edge)
The "color" argument should be passed to the "scatterplot3d" function, but it doesn't work.. Am I missed something here, or the "phylomorphospace3d" can only plot black tips?
Thanks in advance. -Marko