I've been emailing back & forth with a phytools user to try & explain what is done with paintSubTree, plotSimmap, and phylomorphospace with a mapped regime - but I thought some visuals would help & that some other readers (occasional or otherwise) of this blog might find the clarification useful, so I decided to write this quick post.
The first point is that paintSubTree does not paint the tree with colors. The term paint refers to regime painting in Butler & King (2004); i.e., the process of assigning different branches or subtrees to different a priori specified categories or regimes. The states that we choose to assign to these paintings has nothing at all to do with the colors used to visualize the regimes in (for instance) plotSimmap or phylomorphospace, which (if unassigned by the user) are drawn in sequence from palette().
This is what I mean:
Now let's say we want to paint the subtrees arising from nodes 57, 50, 33, and 42 with different regimes. It doesn't matter why we want to do this - maybe we just want to easily visualize the trees with different subtrees in different colors; nor does it matter that the subtree arising out of node 42 is nested within the subtree arising out of node 33. We can do:
Now let's plot the tree with default colors:
no colors provided. using the following legend:
0 1 2 3 4
"black" "red" "green3" "blue" "cyan"
If we want to use different colors, we can just do:
If our sole purpose in painting on regimes was to visualize the tree in this way, we could have used the desired colors as regimes. I.e.,
to exactly the same effect.
Visualizing different regimes in a phylomorphospace works according to the same principle. Here's a quick demo of that using the same tree:
> phylomorphospace(tree,X,colors=cols,node.by.map=TRUE, xlab="x",ylab="y")
That's really all there is to it.