Hi Daniel,
The examples in the help for plotRateThroughTime() show how to do this.
I would recommend that you first calculate the time-binned rates and then do the plotting. This makes it easier to experiment with the plotting without needing to recalculate the rates each time.
So for example:
library(BAMMtools)
data(events.whales)
data(whales)
ephy <- getEventData(whales,events.whales)
rmat1 <- getRateThroughTimeMatrix(ephy, node = 141, nodetype = 'exclude')
rmat2 <- getRateThroughTimeMatrix(ephy, node = 141, nodetype = 'include')
plotRateThroughTime(rmat1, intervals=seq(from = 0, 0.9, by = 0.01),
smooth = TRUE, ylim = c(0, 1.2))
plotRateThroughTime(rmat2, intervals = seq(from = 0, 0.9, by = 0.01),
smooth = TRUE, add = TRUE, intervalCol = 'orange')
To get the proper plot dimensions, you may need to adjust xlim and ylim in the first plot.
And of course you can do this with any number of groups/clades.
If you have more specific questions, let me know.
-Pascal