library(colorspace)

branchvar <- 1

tree <- function(x, y, branch) {

lines(x,y,col=hex(RGB(0.1,0.4,0)))

wadd <- 0.7

if(branch>0) {

alpha <- atan2((y[2]-y[1]),(x[2]-x[1]))

len <- sqrt((y[2]-y[1])^2+(x[2]-x[1])^2)*0.6

tree(c(x[2],x[2]+abs(rnorm(1,1,branchvar))*len*cos(alpha)),

c(y[2],y[2]+abs(rnorm(1,1,branchvar))*len*sin(alpha)),

branch-1)

tree(c(x[2],x[2]+len*cos(alpha+wadd)),

c(y[2],y[2]+len*sin(alpha+wadd)),branch-1)

tree(c(x[2],x[2]+len*cos(alpha-wadd)),

c(y[2],y[2]+len*sin(alpha-wadd)),branch-1)

} else {

points(x[2],y[2],pch=16,

col=hex(RGB(rbeta(1,2.6,0.5),rbeta(1,0.5,3),0)))

}

}

plot.new()

tree(c(0,0.20),c(0,0.20),7)

branchvar <- 1

tree <- function(x, y, branch) {

lines(x,y,col=hex(RGB(0.1,0.4,0)))

wadd <- 0.7

if(branch>0) {

alpha <- atan2((y[2]-y[1]),(x[2]-x[1]))

len <- sqrt((y[2]-y[1])^2+(x[2]-x[1])^2)*0.6

tree(c(x[2],x[2]+abs(rnorm(1,1,branchvar))*len*cos(alpha)),

c(y[2],y[2]+abs(rnorm(1,1,branchvar))*len*sin(alpha)),

branch-1)

tree(c(x[2],x[2]+len*cos(alpha+wadd)),

c(y[2],y[2]+len*sin(alpha+wadd)),branch-1)

tree(c(x[2],x[2]+len*cos(alpha-wadd)),

c(y[2],y[2]+len*sin(alpha-wadd)),branch-1)

} else {

points(x[2],y[2],pch=16,

col=hex(RGB(rbeta(1,2.6,0.5),rbeta(1,0.5,3),0)))

}

}

plot.new()

tree(c(0,0.20),c(0,0.20),7)

You need library colorspace.