Hi Gabriel. I recommend add.simmap.legend in phytools.
For this, though, I would not use par(mfrow) to split the window into multiple plotting devices, but rather xlim or ylim in plotTree (or analogous arguments in plot.phylo) to resize the plot area to accommodate the legend.
You should be able to find worked examples on my blog: http://blog.phytools.org/search?q=add.simmap.legend.
All the best, Liam Liam J. Revell, Associate Professor of Biology University of Massachusetts Boston web: http://faculty.umb.edu/liam.revell/ email: liam.rev...@umb.edu blog: http://blog.phytools.org On 10/27/2016 11:34 AM, Gabriel Yedid wrote:
Hello all, I have a phylo plot where each tip of the tree has a certain trait value associated with it. The trait is represented by a continuously-valued number bounded by x and y (2.0 and 15.0 for these purposes). In order to make display tractable, the values are binned, with each bin being assigned one colour from a sequential palette. I have been able to display the tree as I want, with each tip getting a single coloured square that represents its trait value (within the bin range), but now I want to create a custom legend and put it below the phylo plot. I know how to divide the plot window to position the legend there, but not how to assemble and display the legend itself. What I want is to have a coloured square representing the bin, with text showing the bin's lower and upper limits to the right of the square, [ ] bin_a_lower - bin_a_upper [ ] bin_d_lower - bin_d_upper [ ] bin_b_lower - bin_b_upper [ ] bin_e_lower - bin_e_upper [ ] bin_c_lower - bin_c_upper <etc.> Each of the [ ] would get a different colour specified by the hex codes in the palette's character vector. Does anybody know how to put the legend together from elements that would already be in the workspace? (the palette vector, the bin limit values, etc.) Is there a way to do it with the default legend() function that I just don't know, or does it have to be assembled piece-by-piece? Alternatively, how would I get a colourbar to display in that same space below the plotted tree? cheers, Gabe _______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
_______________________________________________ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/