[R] colouring a tree
Jim Lemon
jim at bitwrit.com.au
Fri Aug 8 13:43:31 CEST 2008
On Thu, 2008-08-07 at 16:15 +0300, Monna Nygård wrote:
> Hi all.
>
> I would be very pleased if someone could help me, as I do not seem to get the different branches of my tree painted in different colours. The closest I get is colouring the names of my samples(=names of the branches). Here is the code.
...
> data <- read.table(file = "S://SEDIM//TRFLP//B12.5_50-700bp.txt" , as.is = TRUE, header = TRUE, sep = "\t", row.names = 1)#define vector with depths of samples
>
In order to run the example, we'll need some data, even if it is made
up.
I think you can get the values you want like this:
x<-ceiling(x/100)
> ...I need to change the tip.color into something else, but what?
> Even better would be if someone could help me changing the colours
> given according to the depth of the sample (according to how high
> a number I have given the samples in row.names), I mean getting
> darker as the samples get deeper etc.. Is there an easy way doing this?
If you want to make colors darker, you can do something like this:
darkenColor<-function(col,colorshift=0.75) {
rgbmat<-col2rgb(col)
ncol<-dim(rgbmat)[2]
rgbmat<-rgbmat*colorshift
return(rgb(rgbmat))
}
This will darker your colors toward black.
Jim
More information about the R-help
mailing list