View source: R/panel.bwplot.superpose.R
panel.bwplot.superpose | R Documentation |
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
.
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)
x, y |
Standard arguments to a lattice panel function.
When |
... |
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 |
pch |
Standard lattice arguments.
The |
fill, fill.alpha |
These are related to the similarly named arguments in |
panel.groups, group.number |
See |
panel.bwplot.superpose
is the user-level function.
panel.bwplot.groups
is the panel.groups
function called by panel.superpose
.
Richard M. Heiberger <rmh@temple.edu>
position
, panel.bwplot.intermediate.hh
,
panel.superpose
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.