R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("dichromat-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('dichromat') Attaching package: 'dichromat' The following object(s) are masked from package:grDevices : colorRamp colorRampPalette > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "colorRamp" > > ### * colorRamp > > flush(stderr()); flush(stdout()) > > ### Name: colorRamp > ### Title: Color interpolation > ### Aliases: colorRamp colorRampPalette > ### Keywords: color > > ### ** Examples > > > ## Here space="rgb" gives palettes that vary only in saturation, as > ## intended. With space="Lab" the steps are more uniform, but the hues > ## are slightly purple. > filled.contour(volcano, color =colorRampPalette(c("red","white","blue")), asp = 1) > filled.contour(volcano, color = colorRampPalette(c("red","white","blue"),space="Lab"), asp = 1) > > ## Interpolating a 'sequential' ColorBrewer palette > YlOrBr <- c("#FFFFD4", "#FED98E", "#FE9929", "#D95F0E", "#993404") > filled.contour(volcano, color = colorRampPalette(YlOrBr,space="Lab"), asp = 1) > filled.contour(volcano, color = colorRampPalette(YlOrBr,space="Lab",bias=0.5), asp = 1) > > ## space="Lab" helps when colors don't form a natural sequence > m<-outer(1:20,1:20,function(x,y) sin(sqrt(x*y)/3)) > rgb.palette<-colorRampPalette(c("red","orange","blue"), space="rgb") > Lab.palette<-colorRampPalette(c("red","orange","blue"), space="Lab") > filled.contour(m,col=rgb.palette(20)) > filled.contour(m,col=Lab.palette(20)) > > > > > cleanEx(); ..nameEx <- "colorschemes" > > ### * colorschemes > > flush(stderr()); flush(stdout()) > > ### Name: colorschemes > ### Title: Color schemes > ### Aliases: colorschemes > ### Keywords: datasets > > ### ** Examples > > opar <- par(mar=c(1,2,1,1)) > layout(matrix(1:6,ncol=1)) > image(1:10,1,matrix(1:10, ncol=1),col=colorschemes$BrowntoBlue.10, + main="Brown to Blue (10)", axes=FALSE) > image(1:100,1,matrix(1:100 ,ncol=1),col=colorRampPalette(colorschemes$BrowntoBlue.10,space="Lab")(100), + main="Brown to Blue Ramp", axes=FALSE) > image(1:10,1,matrix(1:10, ncol=1),col=dichromat(colorschemes$BrowntoBlue.10), + main="Brown to Blue (10) -- deuteranopia", axes=FALSE) > image(1:12,1,matrix(1:12, ncol=1),col=colorschemes$Categorical.12,main="Categorical (12)", axes=FALSE) > image(1:12,1,matrix(1:12, ncol=1),col=dichromat(colorschemes$Categorical.12), + main="Categorical (12) -- deuteranopia", axes=FALSE) > image(1:12,1,matrix(1:12,ncol=1),col=dichromat(colorschemes$Categorical.12, "protan"), + main="Categorical (12) -- protanopia", axes=FALSE) > par(opar) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "dalton" > > ### * dalton > > flush(stderr()); flush(stdout()) > > ### Name: dalton > ### Title: Effects of daltonism (red-green color blindness) > ### Aliases: dalton dalton.colors redp redd greenp greend bluep blued > ### Keywords: datasets > > ### ** Examples > > data(dalton) > par(mfrow=c(3,1)) > image(matrix(1:256,128),col=dalton.colors$deutan) > image(matrix(1:256,128),col=dalton.colors$protan) > image(matrix(1:256,128),col=dalton.colors$normal) > > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "dichromat" > > ### * dichromat > > flush(stderr()); flush(stdout()) > > ### Name: dichromat > ### Title: Remove red-green distinctions from colours > ### Aliases: dichromat > ### Keywords: color > > ### ** Examples > > ## from example(pie) > par(mfrow=c(2,2)) > pie.sales <- c(0.12, 0.3, 0.26, 0.16, 0.04, 0.12) > names(pie.sales) <- c("Blueberry", "Cherry", + "Apple", "Boston Cream", "Other", "Vanilla Cream") > pie(pie.sales) # default colours > pie(pie.sales, + col = c("purple", "violetred1", "green3", "cornsilk", "cyan", "white")) > pie(pie.sales,col=dichromat( c("white", "lightblue", "mistyrose", "lightcyan", + "lavender", "cornsilk"))) # default colours > pie(pie.sales, + col =dichromat(c("purple", "violetred1", "green3", "cornsilk", "cyan", "white"))) > > ## standard color schemes > pie(rep(1,10),col=heat.colors(10)) > pie(rep(1,10),col=dichromat(heat.colors(10))) > pie(rep(1,8),col=palette()) > pie(rep(1,8),col=dichromat(palette())) > > pie(rep(1,15),col=topo.colors(15)) > pie(rep(1,15),col=dichromat(topo.colors(15))) > pie(rep(1,15),col=terrain.colors(15)) > pie(rep(1,15),col=dichromat(terrain.colors(15))) > > pie(rep(1,15),col=cm.colors(15)) > pie(rep(1,15),col=dichromat(cm.colors(15))) > bluescale<-colorRampPalette(c("#FFFFCC","#C7E9B4","#7FCDBB","#40B6C4","#2C7FB8" ,"#253494")) > pie(rep(1,15),col=bluescale(15)) > pie(rep(1,15),col=dichromat(bluescale(15))) > > par(mfrow=c(2,3)) > x<-matrix(rnorm(10*10),10) > redgreen<-colorRampPalette(c("red","green3")) > image(1:10,1:10,x, col=bluescale(10), + main="blue-yellow scale") > image(1:10,1:10,x, col=dichromat(bluescale(10)), main="deutan") > image(1:10,1:10,x,col=dichromat(bluescale(10),"protan"), main="protan") > > image(1:10,1:10,x, col=redgreen(10), + main="red-green scale") > image(1:10,1:10,x, col=dichromat(redgreen(10)), main="deutan") > image(1:10,1:10,x, col=dichromat(redgreen(10),"protan"), main="protan") > > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > ### *