Last data update: 2014.03.03
R: Panel function for bwplot that displays an entire box in the...
panel.bwplot.superpose R 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(c("A","B"), each=52),
y=rep(1:4, 52) + rep(4:5, each=52) + rnorm(104))
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)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
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 an HTML browser interface to help.
Type 'q()' to quit R.
> library(HH)
Loading required package: lattice
Loading required package: grid
Loading required package: latticeExtra
Loading required package: RColorBrewer
Loading required package: multcomp
Loading required package: mvtnorm
Loading required package: survival
Loading required package: TH.data
Loading required package: MASS
Attaching package: 'TH.data'
The following object is masked from 'package:MASS':
geyser
Loading required package: gridExtra
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HH/panel.bwplot.superpose.Rd_%03d_medium.png", width=480, height=480)
> ### Name: panel.bwplot.superpose
> ### Title: Panel function for bwplot that displays an entire box in the
> ### colors coded by groups.
> ### Aliases: panel.bwplot.superpose panel.bwplot.groups
> ### Keywords: dplot
>
> ### ** 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(c("A","B"), each=52),
+ y=rep(1:4, 52) + rep(4:5, each=52) + rnorm(104))
> 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)
Treatment
Week A B
0 4.523568 5.777646
1 6.775678 6.782473
3 6.453206 7.942609
6 8.418624 8.813776
>
> 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)
>
>
>
>
>
>
> dev.off()
null device
1
>