#' @title Color Palettes #' @description Create a vector of n contiguous colors based on rainbow 130 colors. #' @param n the number of colors (> 1) to be in the palette. #' @details .. #' @return A character vector, cv, of color names. #' @author Han-Ming Wu #' @seealso .. #' @examples #' pie(rep(1, 12), col = rainbow130(12)) rainbow130 <- function(n=130){ #rainbow130.rgb <- rgb(read.table("data\\color-rainbow130.txt" , header=FALSE)) value <- c(0.57,0,0,0.59,0,0,0.61,0,0,0.63,0,0,0.65,0,0,0.67,0, 0,0.69,0,0,0.71,0,0,0.73,0,0,0.75,0,0,0.77,0,0,0.79, 0,0,0.81,0,0,0.83,0,0,0.85,0,0,0.865,0,0,0.88,0,0, 0.895,0,0,0.91,0,0,0.925,0,0,0.94,0,0,0.955,0,0,0.97,0, 0,0.985,0,0,1,0,0,1,0.04,0,1,0.08,0,1,0.12,0,1,0.16, 0,1,0.2,0,1,0.24,0,1,0.28,0,1,0.32,0,1,0.36,0,1,0.4, 0,1,0.43,0,1,0.46,0,1,0.49,0,1,0.52,0,1,0.55,0,1, 0.58,0,1,0.61,0,1,0.64,0,1,0.67,0,1,0.7,0,1,0.72,0,1, 0.74,0,1,0.76,0,1,0.78,0,1,0.8,0,1,0.82,0,1,0.84,0,1, 0.86,0,1,0.88,0,1,0.9,0,1,0.91,0,1,0.92,0,1,0.93,0,1, 0.94,0,1,0.95,0,1,0.96,0,1,0.97,0,1,0.98,0,1,0.99,0,1, 1,0,0.98,0.995,0,0.96,0.99,0,0.94,0.985,0,0.92,0.98, 0,0.9,0.975,0,0.88,0.97,0,0.86,0.965,0,0.84,0.96,0, 0.82,0.955,0,0.8,0.95,0,0.79,0.945,0,0.78,0.94,0,0.77, 0.935,0,0.76,0.93,0,0.75,0.925,0,0.74,0.92,0,0.73, 0.915,0,0.72,0.91,0,0.71,0.905,0,0.7,0.9,0,0.67,0.875, 0,0.64,0.85,0,0.61,0.825,0,0.58,0.8,0,0.55,0.775,0, 0.52,0.75,0,0.49,0.725,0,0.46,0.7,0,0.43,0.675,0,0.4, 0.65,0,0.36,0.63,0.035,0.32,0.61,0.07,0.28,0.59,0.105, 0.24,0.57,0.14,0.2,0.55,0.175,0.16,0.53,0.21,0.12, 0.51,0.245,0.08,0.49,0.28,0.04,0.47,0.315,0,0.45,0.35, 0,0.435,0.407,0,0.42,0.464,0,0.405,0.521,0,0.39,0.578, 0,0.375,0.635,0,0.36,0.692,0,0.345,0.749,0,0.33,0.806, 0,0.315,0.863,0,0.3,0.92,0,0.27,0.883,0,0.24,0.846, 0,0.21,0.809,0,0.18,0.772,0,0.15,0.735,0,0.12,0.698, 0,0.09,0.661,0,0.06,0.624,0,0.03,0.587,0,0,0.55,0, 0,0.56,0,0,0.57,0,0,0.58,0,0,0.59,0,0,0.6) rainbow130.rgb <- rgb(matrix(value, ncol=3, byrow=T)) a <- floor(n/130) b <- n-130*a if(b!=0){ if(a!=0){ id <- c(rep(c(1:b), each=(a+1)), rep(c((b+1):130), each=a)) }else{ id <- floor(seq(1, 130, length.out=n)) } }else{ id <- c(rep(c((b+1):130), each=a)) } my.color <- rainbow130.rgb[id] my.color }