bxp {graphics} | R Documentation |
Draw Box Plots from Summaries
Description
bxp
draws box plots based on the given summaries in z
.
It is usually called from within boxplot
, but can be
invoked directly.
Usage
bxp(z, notch = FALSE, width = NULL, varwidth = FALSE,
outline = TRUE, notch.frac = 0.5, log = "",
border = par("fg"), pars = NULL, frame.plot = axes,
horizontal = FALSE, ann = TRUE,
add = FALSE, at = NULL, show.names = NULL,
...)
Arguments
z |
a list containing data summaries to be used in constructing
the plots. These are usually the result of a call to
|
notch |
if |
width |
a vector giving the relative widths of the boxes making up the plot. |
varwidth |
if |
outline |
if |
notch.frac |
numeric in (0,1). When |
border |
character or numeric (vector), the color of the box
borders. Is recycled for multiple boxes. Is used as default for
the |
log |
character, indicating if any axis should be drawn in
logarithmic scale, as in |
frame.plot |
logical, indicating if a ‘frame’
( |
horizontal |
logical indicating if the boxplots should be
horizontal; default |
ann |
a logical value indicating whether the default annotation (title and x and y axis labels) should appear on the plot. |
add |
logical, if true add boxplot to current plot. |
at |
numeric vector giving the locations where the boxplots
should be drawn, particularly when |
show.names |
Set to |
pars , ... |
graphical parameters (etc) can be passed as
arguments to this function, either as a list ( Currently, In addition, The following arguments (or
|
Value
An invisible vector, actually identical to the at
argument,
with the coordinates ("x" if horizontal is false, "y" otherwise) of
box centers, useful for adding to the plot.
Note
When add = FALSE
, xlim
now defaults to xlim =
range(at, *) + c(-0.5, 0.5)
. It will usually be a good idea to
specify xlim
if the "x" axis has a log scale or width
is
far from uniform.
Author(s)
The R Core development team and Arni Magnusson (then at U Washington) who has provided most changes for the box*, med*, whisk*, staple*, and out* arguments.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
Examples
require(stats)
set.seed(753)
(bx.p <- boxplot(split(rt(100, 4), gl(5, 20))))
op <- par(mfrow = c(2, 2))
bxp(bx.p, xaxt = "n")
bxp(bx.p, notch = TRUE, axes = FALSE, pch = 4, boxfill = 1:5)
bxp(bx.p, notch = TRUE, boxfill = "lightblue", frame.plot = FALSE,
outline = FALSE, main = "bxp(*, frame.plot= FALSE, outline= FALSE)")
bxp(bx.p, notch = TRUE, boxfill = "lightblue", border = 2:6,
ylim = c(-4,4), pch = 22, bg = "green", log = "x",
main = "... log = 'x', ylim = *")
par(op)
op <- par(mfrow = c(1, 2))
## single group -- no label
boxplot (weight ~ group, data = PlantGrowth, subset = group == "ctrl")
## with label
bx <- boxplot(weight ~ group, data = PlantGrowth,
subset = group == "ctrl", plot = FALSE)
bxp(bx, show.names=TRUE)
par(op)
## passing gap.axis=* to axis(), PR#18109:
boxplot(matrix(100*rnorm(1e3), 50, 20),
cex.axis = 1.5, gap.axis = -1)# showing *all* labels
z <- split(rnorm(1000), rpois(1000, 2.2))
boxplot(z, whisklty = 3, main = "boxplot(z, whisklty = 3)")
## Colour support similar to plot.default:
op <- par(mfrow = 1:2, bg = "light gray", fg = "midnight blue")
boxplot(z, col.axis = "skyblue3", main = "boxplot(*, col.axis=..,main=..)")
plot(z[[1]], col.axis = "skyblue3", main = "plot(*, col.axis=..,main=..)")
mtext("par(bg=\"light gray\", fg=\"midnight blue\")",
outer = TRUE, line = -1.2)
par(op)
## Mimic S-Plus:
splus <- list(boxwex = 0.4, staplewex = 1, outwex = 1, boxfill = "grey40",
medlwd = 3, medcol = "white", whisklty = 3, outlty = 1, outpch = NA)
boxplot(z, pars = splus)
## Recycled and "sweeping" parameters
op <- par(mfrow = c(1,2))
boxplot(z, border = 1:5, lty = 3, medlty = 1, medlwd = 2.5)
boxplot(z, boxfill = 1:3, pch = 1:5, lwd = 1.5, medcol = "white")
par(op)
## too many possibilities
boxplot(z, boxfill = "light gray", outpch = 21:25, outlty = 2,
bg = "pink", lwd = 2,
medcol = "dark blue", medcex = 2, medpch = 20)