panel.bwplot.superpose: Panel function for bwplot that displays an entire box in the...

View source: R/panel.bwplot.superpose.R

panel.bwplot.superposeR Documentation

Panel function for bwplot that displays an entire box in the colors coded by groups.

Description

Panel function for bwplot that displays an entire box (central dot, box, umbrella, outliers) in the same color, coded by the groups argument. The function is based on panel.superpose.

Usage

panel.bwplot.superpose(x, y, ...,
                       groups=groups,
                       col=rep(trellis.par.get("superpose.symbol")$col,
                               length=length(groups)),
                       pch=trellis.par.get("box.dot")$pch,
                       panel.groups=panel.bwplot.groups)

panel.bwplot.groups(..., col, pch, fill, fill.alpha=NULL, group.number)

Arguments

x, y

Standard arguments to a lattice panel function. When x has class positioned (see position), the position will be forwarded by panel.bwplot.superpose to panel.bwplot.groups.

...

Additional lattice arguments.

groups

Factor to be used for color coding entire boxes: central dot, rectangle, umbrella, and outlier symbol.

col

Colors to be assigned to the levels of the group. The default colors are taken from trellis.par.get("superpose.symbol")$col.

pch

Standard lattice arguments. The pch describes the central dot. The outlier dots are specified in the plot.symbol component of trellis.par.get.

fill, fill.alpha

These are related to the similarly named arguments in panel.bwplot. The fill argument is ignored. It is there to capture the automatically generated fill argument. The defaultNULL value of fill.alpha implies that there is no background color for the boxes. The user can set fill.alpha to a number between 0 and 1. The boxes will be shaded in a lighter version of their color as implied by the groups argument. The value 0 gives a transparent fill, and the value one makes the box the full opaque color.

panel.groups, group.number

See panel.superpose for details.

Details

panel.bwplot.superpose is the user-level function. panel.bwplot.groups is the panel.groups function called by panel.superpose.

Author(s)

Richard M. Heiberger <rmh@temple.edu>

See Also

position, panel.bwplot.intermediate.hh, panel.superpose

Examples

tmp <- data.frame(Response=rnorm(20), Group=factor(rep(LETTERS[1:3], c(5,7,8))))

bwplot(Group ~ Response, data=tmp,
       main="Default panel.bwplot, groups ignored", groups=Group)

bwplot(Group ~ Response, data=tmp,
       main="panel.bwplot.superpose",
       groups=Group, panel=panel.bwplot.superpose)

bwplot(Group ~ Response, data=tmp,
       main="panel.bwplot.superpose with fill specified",
       groups=Group, panel=panel.bwplot.superpose,
       fill.alpha=.33)


bwplot(Group ~ Response, data=tmp,
       main="panel.bwplot.superpose, with color specified",
       groups=Group, panel=panel.bwplot.superpose,
       col=c("forestgreen","blue", "brown"))


Test <- data.frame(id=rep(letters, each=4),
                   Week=rep(c(0,1,3,6), 26),
                   Treatment=rep(factor(c("A","B"), levels=c("A","B")), each=52),
                   y=rep(1:4, 52) + rep(4:5, each=52) + rnorm(104),
                   stringsAsFactors=FALSE)
Test$WeekTrt <- with(Test, interaction(Week, Treatment))
position(Test$Week) <- unique(Test$Week)
position(Test$WeekTrt) <- as.vector(outer(position(Test$Week), c(-.2, .2), `+`))

tapply(Test$y, Test[c("Week", "Treatment")], median)

bwplot( y ~ WeekTrt, groups = Treatment, data = Test,
      main="default panel.bwplot, groups ignored")

bwplot( y ~ WeekTrt, groups = Treatment, data = Test,
      panel=panel.bwplot.superpose,
      scales=list(x=list(limits=c(-1, 7))),
      main="Minimal use of panel.bwplot.superpose")

bwplot( y ~ WeekTrt, groups = Treatment, data = Test,
       panel=panel.bwplot.superpose,
       scales=list(x=list(limits=c(-1, 7), at=position(Test$Week))),
       box.width=.3,
       xlab="Week",
       pch=c(17, 16),
       key=list(col=trellis.par.get()$superpose.symbol$col[1:2],
           border=TRUE, title="Treatment", cex.title=1, columns=2,
           text=list(levels(Test$Treatment)),
           points=list(pch=c(17, 16))),
       par.settings=list(plot.symbol=list(pch=c(17, 16), cex=.5)),
       main="panel.bwplot.superpose with additional annotations")


bwplot( y ~ WeekTrt, groups = Treatment, data = Test,
       panel=panel.bwplot.superpose,
       scales=list(x=list(limits=c(-1, 7), at=position(Test$Week))),
       box.width=.3,
       xlab="Week",
       pch=c(17, 16),
       key=list(col=trellis.par.get()$superpose.symbol$col[1:2],
           border=TRUE, title="Treatment", cex.title=1, columns=2,
           text=list(levels(Test$Treatment)),
           points=list(pch=c(17, 16))),
       par.settings=list(plot.symbol=list(pch=c(17, 16), cex=.5)),
       main="panel.bwplot.superpose with fill and more complex panel.groups",
       panel.groups = function(...) {
           panel.stripplot(...)
           panel.bwplot.groups(...)
       },
       fill.alpha=.33,
       jitter.data = TRUE)


HH documentation built on May 29, 2024, 6:24 a.m.