Compute distinguishable color palette in R

I am using R to create a plot that contains 20 different groups and I would like to color each one differently. I am also familiar with Matlab and while working with this program I found that the matlab file "differishable_colors" is best for distinguishing different colors 1 . I looked at the "rainbow", "rainbow_hcl" and "prewer" palettes, but none of them look as good as "differishable_colors.mat". I'm wondering if anyone knows of a function in R that will create the same palette as matlab's "differishable_colors.mat" function?

+3


source to share


2 answers


This function in MatLab appears to iteratively perform RBG space searches for color sets that are as different as possible from each other. I don't know that in R, but we can get closer.

We can find a multi-color palette that suits our needs (perhaps using http://colorbrewer2.org/ ) and use the seed color to create a colorRampPalette

for any number of flowers.



pal<-colorRampPalette(c('#e41a1c','#377eb8','#4daf4a','#984ea3','#ff7f00'))
N=10
plot(rnorm(N),rnorm(N),pch=16,col=pal(N),cex=3)

      

+1


source


The R package Polychrome

provides tools for quality palettes with many (20 or more) colors. It comes with two vignettes providing the provided palettes and tools for creating palettes .



0


source







All Articles