Learn R Programming

cwhmisc (version 1.0.0)

plt: Plot depending on switch, Create multiple plots with title and time stamp

Description

- plt executes a (series of) plotting function(s) depending on a switch, may be useful in source. - plotTitStamp creates an array of plot panels and executes a (series of) plotting function(s) and adds a title and a time stamp to the overall plot. - pltTSV is a shortcut for plt(VIEW,plotTitStamp(...),file,horizontal) - pltCharMat uses output from charMat to plot numerical matrices as characters

Usage

plt(VIEW,f,file="",horizontal = FALSE)
plotTitStamp(rows, cols, tit, stampl, f=function(x) 0,
      cex=1.5,reset=TRUE,outer=TRUE,oma=c(2,2,4,2),mar=c(4,4,2,1))
pltTSV(VIEW="see", rows, cols, tit, stampl, f=function(x) 0,
      cex=1.5,reset=TRUE,outer=TRUE,oma=c(2,2,4,2),mar=c(4,4,2,1),file=stampl,horizontal=TRUE)
pltCharMat(m,tit)

Arguments

VIEW
"NA" or NA, nothing will be done. "see", the plot will be created in the active plot window. "eps", the plot will be saved to file ".eps" "ps", the plot will be created in a postscript file ".ps". "ps+p", like with "ps", the file wi
f
A function to plot the individual plot panels. It can also be a statement sequence {...}
file
Name of file to write to.
horizontal
Landscape, if TRUE.
rows
Number of rows of panels.
cols
Number of columns of panels.
tit
Overall title for plot. A vector of one or two elements. If an element is an expression, plotmath will be used
stampl
Label for time stamp.
cex
Font size used for tit.
reset
Should previous rows, cols be restored after execution.
outer
Passed on to mtext.
oma
Outer margin used in initial par(...).
mar
Lines of margin used in initial par(...).
m
numerical matrix

Value

  • Are called for their side effect to produce a plot and/or generate a file.

WARNING

The sequence of functions contained in f MUST NOT contain any call to postscript, because this would try to open another ps device without closing the old one!

Examples

Run this code
# see also \code{\link{plotTitStamp}}
x <- rnorm(100); y <- rnorm(100)+1; z <- y+rlnorm(100)
plt("see", {plot(x,y,xlab="this is my x");abline(reg=lm(y~x),lty=2);plot(x,z,pch=3)})
plt("ps", plot(y,x-3*y) )
plt("ps+p", plot(y,x-3*y) )
plotTitStamp(1, 2, "1 by 2 plot", "Example 1", {plot(x,y,xlab="my x");
  abline(reg=lm(y~x),lty=2);plot(x,z,pch=3)})
plotTitStamp(1, 1, "1 by 2 plot", "Ex2", plot(y,x-3*y) )
  m <- matrix(rnorm(500),nrow=50,ncol=10)
  pltCharMat(m,"Random example")

Run the code above in your browser using DataLab