macroevolution / bamm

A program for multimodel inference on speciation and trait evolution
GNU General Public License v2.0
33 stars 10 forks source link

plot.bammdata / multi plot / color mapping #83

Closed drabosky closed 10 years ago

drabosky commented 10 years ago

I think using plot.bammdata to plot the same color scheme on a set of trees (or subtrees) is not very intuitive - it involves using multiple functions and isn't clear how to change the color scheme. Can we make this simpler, such that plot.bammdata returns the color mapping invisibly (say, a "colorbreaks" variable, which then can just be recycled as an argument to subsequent calls?

E.g.: I want to plot the first 2 samples from the posterior for some analysis, using the color mapping from the mean:

sub1 <- subsetEventData(ed, index =1 ) sub2 <- subsetEventData(ed, index=2 )

Here we get color mapping for overall bammdata object but don't plot

xx <- plot.bammdata(ed, pal = "temperature", show = F)

now plot:

plot.new() par(mfrow=c(1,2))

plot.bammdata(s1, colorbreaks = xx$colorbreaks ) plot.bammdata(s2, colorbreaks = xx$colorbreaks)

This seems much simpler to me. Is there a reason for not doing it like this? I think users will want to do this type of plot.

drabosky commented 10 years ago

i might be missing something, but it also seems that the construct i described above would make it easier for the user to recycle the color mapping in other contexts e.g., making custom interpretative color bars etc to show rate distributions.

as it is, the user now has to also understand too many different things: dtRates, assignColorBreaks, plus all the arguments (like tau, NCOL, and the double obj$dtrates$rates construct). What they will really want to do is just call plot.bammdata with the default color scheme (maybe changing pal), and then say "oh, that looks nice", and immediately recycle the same scheme on subtrees etc without having to understand anything else.

drabosky commented 10 years ago

I was a little confused here. I see that plot.bammdata already returns the relevant color matrix, just was thrown by seeing the calls to dtrates then assignColorBreaks in example

blueraleigh commented 10 years ago

They are a bit different, though. The color breaks are made by binning the rates into percentiles but the matrix that is returned right now is just the density estimate for the distribution of rates. Wouldn't be difficult to additionally return the color breaks to make things a bit simpler.

blueraleigh commented 10 years ago

OK, I changed this. See new documentation of plot.bammdata.