Hi,

On Jun 10, 2013, at 3:46 PM, Adams, Jean wrote:

> It will be hard to come up with 20 clearly distinguishable colors.  Check
> out the website http://colorbrewer2.org/ and the R package RColorBrewer.
> It does not have a 20-color palette, but it does have some 8- to 12-color
> palettes that are very nice.
> 
> library(RColorBrewer)
> display.brewer.all(n=NULL, type="all", select=NULL, exact.n=TRUE)
> 

It sounds like Brian is looking for categorical coloring rather than divergent 
coloring.  The Glasbey LUT works really well in image processing for just such 
purposes.  It would be easy to use that within R for your lines.

http://www.bioss.ac.uk/people/chris/colorpaper.pdf

You might be able to snag the color table out of this collection of Java 
plugins for ImageJ software. 

http://www.dentistry.bham.ac.uk/landinig/software/morphology.zip

Within that archive is a text file called glasbey.lut which is a simple text 
file of RGB color values.

Cheers,
Ben




> You could use these colors in combination with line type to build up to 72
> unique combinations.  For example ...
> 
> nuniq <- ncol(mat)
> mycols <- rep(brewer.pal(12, "Set3"), length=nuniq)
> myltys <- rep(1:6, rep(12, 6))[1:nuniq]
> 
> for(k in 1:nuniq){
> plot(density(mat[,k]), col=mycols[k], xlab='', ylab='', axes=F, main=F,
> lwd=3, lty=myltys[k])
> par(new=TRUE)
> }
> legend('topright', legend=snames, col=mycols, lty=myltys, lwd=3)
> 
> Jean
> 
> 
> 
> On Mon, Jun 10, 2013 at 12:33 PM, Brian Smith <bsmith030...@gmail.com>wrote:
> 
>> 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.
>> 
> 
>       [[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.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

______________________________________________
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