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("gridBase-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('gridBase') Loading required package: grid > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "baseViewports" > > ### * baseViewports > > flush(stderr()); flush(stdout()) > > ### Name: baseViewports > ### Title: Generate grid Viewports from Base Plot > ### Aliases: baseViewports > ### Keywords: dplot > > ### ** Examples > > par(oma=rep(1, 4), mfrow=c(1, 2), xpd=NA) > plot(1:10) > vps <- baseViewports() > pushViewport(vps$inner) > grid.rect(gp=gpar(lwd=3, col="red")) > pushViewport(vps$figure) > grid.rect(gp=gpar(lwd=3, col="green")) > pushViewport(vps$plot) > grid.rect(gp=gpar(lwd=3, col="blue")) > grid.points(1:10, 10:1) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "gridOMI" > > ### * gridOMI > > flush(stderr()); flush(stdout()) > > ### Name: Set Base Plot Regions > ### Title: Set Base Plotting Regions from Grid Viewport > ### Aliases: gridOMI gridFIG gridPLT gridPAR > ### Keywords: dplot > > ### ** Examples > > opar <- par(no.readonly=TRUE) > # gridFIG > grid.newpage() > pushViewport(viewport(width=0.5, height=0.5)) > grid.rect(gp=gpar(col="grey", lty="dashed")) > par(fig=gridFIG()) > par(new=TRUE) > plot(1:10) > # multiple plots > # NOTE the use of par(mfg) > # gridOMI > par(opar) > grid.newpage() > pushViewport(viewport(width=0.5, height=0.5)) > grid.rect(gp=gpar(col="grey", lty="dashed")) > par(omi=gridOMI()) > par(mfrow=c(2, 2), mfg=c(1, 1), mar=c(3, 3, 1, 0)) > for (i in 1:4) { + plot(i) + } > # gridPLT > par(opar) > grid.newpage() > pushViewport(viewport(width=0.5, height=0.5)) > grid.rect(gp=gpar(col="grey", lwd=5)) > par(plt=gridPLT()) > par(new=TRUE) > plot(1:10) > # gridFIG with par(omi) set > par(opar) > grid.newpage() > par(omi=rep(1, 4)) > pushViewport(viewport(width=0.5, height=0.5)) > grid.rect(gp=gpar(col="grey", lwd=5)) > par(fig=gridFIG()) > par(new=TRUE) > plot(1:10) > # gridPLT with par(omi) set > par(opar) > grid.newpage() > par(omi=rep(1, 4)) > pushViewport(viewport(width=0.5, height=0.5)) > grid.rect(gp=gpar(col="grey", lwd=5)) > par(plt=gridPLT()) > par(new=TRUE) > plot(1:10) > # gridPAR > par(opar) > grid.newpage() > pushViewport(viewport(width=0.5, height=0.5, + gp=gpar(col="red", lwd=3, lty="dotted"))) > grid.rect(gp=gpar(col="grey", lwd=5)) > par(fig=gridFIG()) > par(gridPAR()) > par(new=TRUE) > plot(1:10, type="b") > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > ### *