Are there any good packages for colour palettes in R that can handle many data classes? I have 16 sequential data classes. I tried RColorBrewer but it has a max of 9 data cl
As Kevin Wright I found that the best for me was to do manually a palette. Here I contribute my palette and a way to plot it in polygons.
# https://stackoverflow.com/questions/15534032/suppress-redraw-when-calling-polygon-in-r
cuts <- function(x) {
n <- length(x) %/% 4
map <- rep(c(rep(TRUE,4),FALSE), n)
result <- rep(NA, n*5)
result[map] <- x
result
}
{
rownumber <- 5
xfloor <- 0
yheight <- 6
widthCol <- 1
colSpacer <- 0.2
# names in: http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf
manualcolors<-c('black','forestgreen', 'red2', 'orange', 'cornflowerblue',
'magenta', 'darkolivegreen4', 'indianred1', 'tan4', 'darkblue',
'mediumorchid1','firebrick4', 'yellowgreen', 'lightsalmon', 'tan3',
"tan1",'darkgray', 'wheat4', '#DDAD4B', 'chartreuse',
'seagreen1', 'moccasin', 'mediumvioletred', 'seagreen','cadetblue1',
"darkolivegreen1" ,"tan2" , "tomato3" , "#7CE3D8","gainsboro")
squareVec<-c(rep(rownumber,ceiling(length(manualcolors)/rownumber) ) )
map<-mapybot<-mapytop<-mapxbot<-mapxtop<-numeric()
for (i in 1:length(squareVec)){
map <- seq(0, 5, length.out = squareVec[i]+1 )
mapybot <- c(mapybot,(map[1:(length(map)-1)] ) )
mapytop <- mapybot + (map[2]-map[1] )
mapxbot <- c(mapxbot,(rep(xfloor + (widthCol*(i-1)), squareVec[i]) ) )
mapxtop <- c(mapxtop,(rep(xfloor + (widthCol* i ) - colSpacer,squareVec[i]) ) )
}
x <- cbind(mapxbot,mapxbot,mapxtop,mapxtop )
y <- cbind(mapybot,mapytop,mapytop,mapybot )
opar<-par(no.readonly=TRUE) # save par
par(mar=c(0,0,0,0), font=2)
plot("", xlim=c(-0.2,max(x)), ylim=c(min(y), max(y)),
ylab = "", xaxt='n',
xlab = "", yaxt='n',
main = NULL)
polygon(x=cuts(t(x)), y=cuts(t(y)), col=manualcolors, lwd=2)
text(x=t(x[1:length(manualcolors)]),
y=t(y[1:length(manualcolors)])+(yheight/rownumber)/2,
labels= manualcolors,
cex=0.8, col="white", pos=4
)
par(opar) # restore par
}