Hi,

I was trying to make a density plot with 13 samples. To distinguish each
sample, it would be good if each color is as different as possible from the
other colors. I could use the built in function, but that does not do more
than 8 colors and then goes back to recycling the cols. If I use a palette,
then it is really difficult to distinguish between the colors.

So, is there a way that I can select a large number of colors (i.e. perhaps
20) that are as different from each other as possible?

Here is my example code using the palette:

**********************
mat <- matrix(sample(1:1000,1000,replace=T),nrow=20,ncol=20)
snames <- paste('Sample_',1:ncol(mat),sep='')
colnames(mat) <- snames

mycols <- palette(rainbow(ncol(mat)))

for(k in 1:ncol(mat)){
  plot(density(mat[,k]),col=mycols[k],xlab='',ylab='',axes=F,main=F)
  par(new=T)
}

legend(x='topright',legend=snames,fill=mycols)

****************************

thanks!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to