Tips
color.gen <- function( color.start = "black", color.finish = "grey75", number = 5 ){ ramp <- colorRamp(c(color.start,color.finish)) colors <- rgb( ramp( seq(0,1, length = number)), max = 255) return(colors) }
color.grid <- expand.grid( list( x=c(1:4), y=c(1,2), start=c("black","red","orange","yellow","green","blue","purple","grey"), end=c("white","grey75","grey50","grey25","black") ) ) function.of.panel <- function( x, y, subscripts, data = color.grid){ colors.being.used <- data[subscripts[1],c("start","end")] colors.of.plot <- color.gen( color.start = as.character(colors.being.used[1,1]), color.finish = as.character(colors.being.used[1,2]), number = 8 ) #cat("\ndata\n");print(data[subscripts,]) #cat("\ncolors\n");print(colors.being.used) #cat("\ncolors\n");print(colors.of.plot) panel.points( x, y, col = colors.of.plot ) } lat.color <- xyplot( y ~ x | as.factor(start) + as.factor(end), data = color.grid, panel = function.of.panel, ylim = c(-1,4), xlim = c(-1,6), asp ="iso", # Units have the same interval length on the X and Y axis xlab = NULL, ylab = NULL, main = "Color Generator", scales = list(draw=FALSE), # Do not produce axis labels or ticks # key=list( # text=list( # c("Start","End"), # col=c("#FFE6CB","#C9FECC"), # # Hexadecimal colors may be used, as long as they are in quotes # font = 2 # # Bold Font # ), # space="right", # background="black" # # Color behind text # # ) # Did not produce this key, as it may be confusing. # It did use some new 'techniques' though, so it was left commented out ) pdf("color.gen.pdf",width=10,height=10) #Another way to produce the PDF output #1. Do all of the work #2. Start the PDF #3. Print the output #4. Close the PDF print(lat.color) dev.off()