
bxp
draws box plots based on the given summaries in z
.
It is usually called from within boxplot
, but can be
invoked directly.
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, add = FALSE, at = NULL, show.names = NULL, ...)
boxplot
, but can be generated in any fashion.notch
is TRUE
, a notch is drawn in each
side of the boxes. If the notches of two plots do not overlap then
the medians are significantly different at the 5 percent level.varwidth
is TRUE
, the boxes are drawn
with widths proportional to the square-roots of the number of
observations in the groups.outline
is not true, the outliers are not
drawn.notch = TRUE
, the
fraction of the box width that the notches should use.boxcol
, medcol
, whiskcol
, staplecol
,
and outcol
options (see below).
plot.default
.box
) should be drawn; defaults to TRUE
, unless
axes = FALSE
is specified.FALSE
means vertical boxes.add = TRUE
; defaults to
1:n
where n
is the number of boxes.TRUE
or FALSE
to override the
defaults on whether an x-axis label is printed for each group.pars
) or
normally(...
), see the following. (Those in ...
take precedence over those in pars
.) Currently, yaxs
and ylim
are used ‘along the
boxplot’, i.e., vertically, when horizontal
is
false, and xlim
horizontally.
xaxt
, yaxt
, las
, cex.axis
, and
col.axis
are passed to axis
, and main
,
cex.main
, col.main
, sub
, cex.sub
,
col.sub
, xlab
, ylab
, cex.lab
, and
col.lab
are passed to title
.
In addition, axes
is accepted (see
plot.window
), with default TRUE
.
The following arguments (or pars
components) allow further
customization of the boxplot graphics. Their defaults are typically
determined from the non-prefixed version (e.g., boxlty
from
lty
), either from the specified argument or pars
component or the corresponding par
one.
at
and
typically is $0.8$.
col
and will
in future default to par("bg")
).
medpch = NA
suppresses the
point, and medlty = "blank"
does so for the line.
Note thatmedlwd
defaults to
$3x$ the default lwd
.
"dashed"
), width, and color.
outlty = "blank"
suppresses the
lines and outpch = NA
suppresses points.
at
argument,
with the coordinates ("x" if horizontal is false, "y" otherwise) of
box centers, useful for adding to the plot.
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 = FALSE,
outl = FALSE, main = "bxp(*, frame= FALSE, outl= 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)
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)
Run the code above in your browser using DataLab