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("pixmap-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('pixmap') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "addlogo-methods" > > ### * addlogo-methods > > flush(stderr()); flush(stdout()) > > ### Name: addlogo-methods > ### Title: Methods for Adding a Pixmap Logo to a Plot > ### Aliases: addlogo addlogo-methods addlogo,pixmap-method > ### Keywords: methods > > ### ** Examples > > x <- read.pnm(system.file("pictures/logo.ppm", package="pixmap")[1]) > plot(x) > for (i in 1:7) + addlogo(x, px=c(0, (101/77)*11), py=c((i-1)*11, i*11), asp=1) > > > > cleanEx(); ..nameEx <- "channels-methods" > > ### * channels-methods > > flush(stderr()); flush(stdout()) > > ### Name: channels-methods > ### Title: Methods for Channel Manipulation > ### Aliases: addChannels getChannels addChannels-methods > ### getChannels-methods addChannels,pixmapRGB-method > ### getChannels,pixmapChannels-method > ### Keywords: methods > > ### ** Examples > > x <- pixmapRGB(rep(1:5, 3), nrow=4) > plot(x) > print(x) Pixmap image Type : pixmapRGB Size : 4x4 Resolution : 1x1 Bounding box : 0 0 4 4 > > getChannels(x) , , red [,1] [,2] [,3] [,4] [1,] 0.00 1.00 0.75 0.50 [2,] 0.25 0.00 1.00 0.75 [3,] 0.50 0.25 0.00 1.00 [4,] 0.75 0.50 0.25 0.00 , , green [,1] [,2] [,3] [,4] [1,] 0.25 0.00 1.00 0.75 [2,] 0.50 0.25 0.00 1.00 [3,] 0.75 0.50 0.25 0.00 [4,] 1.00 0.75 0.50 0.25 , , blue [,1] [,2] [,3] [,4] [1,] 0.50 0.25 0.00 1.00 [2,] 0.75 0.50 0.25 0.00 [3,] 1.00 0.75 0.50 0.25 [4,] 0.00 1.00 0.75 0.50 > getChannels(x, colors=c("red", "green")) , , red [,1] [,2] [,3] [,4] [1,] 0.00 1.00 0.75 0.50 [2,] 0.25 0.00 1.00 0.75 [3,] 0.50 0.25 0.00 1.00 [4,] 0.75 0.50 0.25 0.00 , , green [,1] [,2] [,3] [,4] [1,] 0.25 0.00 1.00 0.75 [2,] 0.50 0.25 0.00 1.00 [3,] 0.75 0.50 0.25 0.00 [4,] 1.00 0.75 0.50 0.25 > > y = addChannels(x) > plot(y) > print(y) Pixmap image Type : pixmapGrey Size : 4x4 Resolution : 1x1 Bounding box : 0 0 4 4 > > ## extract only the red channel > y = addChannels(x, coef=c(1,0,0)) > plot(y) > > > > cleanEx(); ..nameEx <- "pixmap" > > ### * pixmap > > flush(stderr()); flush(stdout()) > > ### Name: pixmap > ### Title: Pixmap Images > ### Aliases: pixmap pixmapRGB pixmapGrey pixmapIndexed plot,pixmap-method > ### show,pixmap-method [,pixmap-method > ### Keywords: color > > ### ** Examples > > ## A simple example > x <- pixmapIndexed(rep(1:8, 9), nrow=6, col=terrain.colors(8)) > plot(x) > > ## The same with different colors, and passing the function instead of > ## a color vector > x <- pixmapIndexed(rep(1:8, 9), nrow=6, col=rainbow) > plot(x) > plot(x, asp=.5, axes=TRUE) > > ## Read data from a file > x <- read.pnm(system.file("pictures/logo.ppm", package="pixmap")[1]) > plot(x) > > ## Another example that math can be beautiful > x <- seq(-3,3,length=100) > z1 <- outer(x,x,function(x,y) abs(sin(x)*sin(y))) > z2 <- outer(x,x,function(x,y) abs(sin(2*x)*sin(y))) > z3 <- outer(x,x,function(x,y) abs(sin(x)*sin(2*y))) > > ## Notice that we specify a bounding box to get the correct > ## coordinates on the axes. z1, z2 and z3 are used as red, > ## green and blue channel, respectively. > z <- pixmapRGB(c(z1,z2,z3), 100, 100, bbox=c(-1,-1,1,1)) > plot(z, axes=TRUE) > > ## look at a grey version > plot(as(z, "pixmapGrey")) > > ## subsetting works as expected > plot(z[1:20,]) > plot(z[,1:40]) > plot(z[1:20,10:40]) > > > > cleanEx(); ..nameEx <- "pnm" > > ### * pnm > > flush(stderr()); flush(stdout()) > > ### Name: pnm > ### Title: Read/Write Portable Anymap Images > ### Aliases: write.pnm read.pnm read.pnmdata read.pnmhead > ### Keywords: file color > > ### ** Examples > > x <- read.pnm(system.file("pictures/logo.ppm", package="pixmap")[1]) > plot(x) > print(x) Pixmap image Type : pixmapRGB Size : 77x101 Resolution : 1x1 Bounding box : 0 0 101 77 > > x <- read.pnm(system.file("pictures/logo.pgm", package="pixmap")[1]) > plot(x) > > x <- read.pnm(system.file("pictures/logo.pbm", package="pixmap")[1]) > plot(x) > > > > ### *