plt {cwhmisc} | R Documentation |
- pltCharMat
uses output from charMat
to plot numerical matrices as characters.
- pltRCT
executes a (series of) plotting function(s) under the control of some useful switches, may be useful in source
.
- histRCT
creates a (series of) histogram(s), uses pltRCT
.
- SplomT
creates a scatterplot matrix,
pltCharMat(m,tit) pltRCT(rows, cols, tit="", f = function(x) 0, cex = 1.5, reset = TRUE, outer = TRUE, oma = c(2, 2, 4, 2), mar = c(4, 4, 2, 1)) histRCT(data, rows = round(sqrt(ncol(data))), cols = ceiling(ncol(data)/rows), breaks = "Sturges", mainL = deparse(substitute(data)), mainC = colnames(eval(substitute(data)))) SplomT(data, mainL = deparse(substitute(data)), xlabL = "", hist = "h", adjust = 1, hist.col = trellis.par.get("strip.background")$col[5], cex.diag = 1, h.diag=0.4, colYonX = "red", colXonY = "blue", ...)
m |
Numerical matrix |
tit |
Overall title for plot. A vector of one or two elements. If
an element is an expression , plotmath will be used. |
rows |
Number of rows of panels |
cols |
Number of columns of panels |
f |
A function to plot the individual plot panels. It can also be a statement sequence {...}. |
cex |
Font size used for tit |
reset |
Should previous rows, cols be restored after execution. See note |
outer |
Passed on to mtext. |
oma |
Outer margin used in initial par(...). |
mar |
Lines of margin used in initial par(...). |
data |
Matrix or dataframe containing data, varibles in columns |
breaks |
Breaks for histogram |
mainL |
Label on top of scatterplot matrix or matrix of histograms |
mainC |
Labels on top of each of the histograms, should be character vector of length = number of columns of data |
xlabL |
Label for x axis |
hist |
"h" = histogram, "d" = density curve, "b" = both |
adjust |
factor to adjust smoothing window for density curve |
hist.col |
colour for the bars of the histograms |
cex.diag |
correction factor for font height of correlations and names in the diagonal |
h.diag |
placement of the variable name in the diagonal panel, =0 means on the lower border, = 0.5 in the middle between lower and upper border |
colYonX, colXonY |
colour of smoothing lines, y on x and x on y |
... |
Parameters passed on to upper.panel,lower.panel,diag.panel |
These functions are called for their side effect to produce a plot.
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!
oldpar <- par(mfrow = c(rows, cols),oma=oma,mar=mar) is called at the
beginning of pltRCT. Uses splom
, [lattice:extend.limits]extend.limits, and datetime
.
If you have n
panels you want to plot in a nearly quadratic arrangement, use rows = round(sqrt(n)), cols=ceiling(n/rows)
(tending to slightly "landscape"). This is very similar to n2mfrow
.
histRCT drops columns with less than 2 legal (non-NA)
values. For empty matrices no plot will be generated.
Christian W. Hoffmann, c-w.hoffmann@sunrise.ch,
http://www.wsl.ch/personal_homepages/hoffmann/index_EN
, with the assistance of
Deepayan Sarkar deepayan@cs.wisc.edu.
## Not run: x <- rnorm(100); y <- rnorm(100)+1; z <- y+rlnorm(100) pltRCT(1,1,f={plot(x,y,xlab="this is my x");abline(reg=lm(y~x),lty=2);plot(x,z,pch=3)}) nr <- 100; nc <- 8; data <- as.data.frame(matrix(rnorm(nr*nc),nrow=nr,ncol=nc)) data[,nc] <- data[,nc-2] + 0.3*data[,nc-1] #generate higher correlations data[,nc-1] <- data[,nc-1] + 0.9*data[,nc] colnames(data)<-paste("vw",letters[1:nc],sep="") SplomT(data,mainL="",hist="d",cex.diag=0.6,hist.col="green") SplomT(data,mainL="",hist="b",adjust=0.4,cex.diag = 0.5) pltHist(data) pltRCT(1, 1, tit="1 by 2 plot", f=plot(y,x-3*y) ) pltRCT(1, 2, f={plot(x,y,xlab="my x"); abline(reg=lm(y~x),lty=2);plot(x,z,pch=3)}) m <- matrix(rnorm(500),nrow=50,ncol=10) pltCharMat(m,"Random example") ## End(Not run)