It depends what you are trying to achieve. Some approaches could be easily automatized (e.g. my second example).
IMHO you have to color your tree manually if you want to give each branch a different color depending on its taxonomia or something like that, e.g.:
library("ape")
tree <- read.tree("tree.mod")
tree$edge
# [,1] [,2]
#[1,] 5 6 # root -> a:b
#[2,] 6 1 # == "a"
#[3,] 6 2 # == "b"
#[4,] 5 7 # root -> c:d
#[5,] 7 3 # == "c"
#[6,] 7 4 # == "d"
cols <- rep(c("red", "green"), each=3)
plot.phylo(tree, edge.col=cols)
An easy example which could be done automatically is to color the last leaves, e.g.:
ntips <- length(tree$tip.label)
cols <- c(rainbow(ntips), rep("black", nrow(tree$edge)-ntips+1))
plot.phylo(tree, edge.col=cols[tree$edge[,2]])
EDIT: You have to order the labels by tree$edge[,2]
before matching them. Please find an example below:
library("ape")
tree <- read.tree("tree.mod")
myColors <- c(node="black", a="red", b="green", c="blue", d="purple")
myLabels <- c(tree$tip.label, tree$node.label)
## match colors and labels (nomatch == node => select idx 1)
## (myLabels are reordered by edge ordering
selColors <- myColors[match(myLabels[tree$edge[,2]], names(myColors), nomatch=1)]
plot.phylo(tree, edge.col=selColors)