Produce boxandwhisker plot(s) of the given (grouped) values.
1 2 3 4 5 6 7 8 9 10 11  boxplot(x, ...)
## S3 method for class 'formula'
boxplot(formula, data = NULL, ..., subset, na.action = NULL)
## Default S3 method:
boxplot(x, ..., range = 1.5, width = NULL, varwidth = FALSE,
notch = FALSE, outline = TRUE, names, plot = TRUE,
border = par("fg"), col = NULL, log = "",
pars = list(boxwex = 0.8, staplewex = 0.5, outwex = 0.5),
horizontal = FALSE, add = FALSE, at = NULL)

formula 
a formula, such as 
data 
a data.frame (or list) from which the variables in

subset 
an optional vector specifying a subset of observations to be used for plotting. 
na.action 
a function which indicates what should happen
when the data contain 
x 
for specifying data from which the boxplots are to be
produced. Either a numeric vector, or a single list containing such
vectors. Additional unnamed arguments specify further data
as separate vectors (each corresponding to a component boxplot).

... 
For the For the default method, unnamed arguments are additional data
vectors (unless 
range 
this determines how far the plot whiskers extend out
from the box. If 
width 
a vector giving the relative widths of the boxes making up the plot. 
varwidth 
if 
notch 
if 
outline 
if 
names 
group labels which will be printed under each boxplot. Can be a character vector or an expression (see plotmath). 
boxwex 
a scale factor to be applied to all boxes. When there are only a few groups, the appearance of the plot can be improved by making the boxes narrower. 
staplewex 
staple line width expansion, proportional to box width. 
outwex 
outlier line width expansion, proportional to box width. 
plot 
if 
border 
an optional vector of colors for the outlines of the
boxplots. The values in 
col 
if 
log 
character indicating if x or y or both coordinates should be plotted in log scale. 
pars 
a list of (potentially many) more graphical parameters,
e.g., 
horizontal 
logical indicating if the boxplots should be
horizontal; default 
add 
logical, if true add boxplot to current plot. 
at 
numeric vector giving the locations where the boxplots should
be drawn, particularly when 
The generic function boxplot
currently has a default method
(boxplot.default
) and a formula interface (boxplot.formula
).
If multiple groups are supplied either as multiple arguments or via a
formula, parallel boxplots will be plotted, in the order of the
arguments or the order of the levels of the factor (see
factor
).
Missing values are ignored when forming boxplots.
List with the following components:
stats 
a matrix, each column contains the extreme of the lower whisker, the lower hinge, the median, the upper hinge and the extreme of the upper whisker for one group/plot. If all the inputs have the same class attribute, so will this component. 
n 
a vector with the number of observations in each group. 
conf 
a matrix where each column contains the lower and upper extremes of the notch. 
out 
the values of any data points which lie beyond the extremes of the whiskers. 
group 
a vector of the same length as 
names 
a vector of names for the groups. 
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
Chambers, J. M., Cleveland, W. S., Kleiner, B. and Tukey, P. A. (1983) Graphical Methods for Data Analysis. Wadsworth & Brooks/Cole.
Murrell, P. (2005) R Graphics. Chapman & Hall/CRC Press.
See also boxplot.stats
.
boxplot.stats
which does the computation,
bxp
for the plotting and more examples;
and stripchart
for an alternative (with small data
sets).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  ## boxplot on a formula:
boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
# *add* notches (somewhat funny here):
boxplot(count ~ spray, data = InsectSprays,
notch = TRUE, add = TRUE, col = "blue")
boxplot(decrease ~ treatment, data = OrchardSprays,
log = "y", col = "bisque")
rb < boxplot(decrease ~ treatment, data = OrchardSprays, col = "bisque")
title("Comparing boxplot()s and nonrobust mean +/ SD")
mn.t < tapply(OrchardSprays$decrease, OrchardSprays$treatment, mean)
sd.t < tapply(OrchardSprays$decrease, OrchardSprays$treatment, sd)
xi < 0.3 + seq(rb$n)
points(xi, mn.t, col = "orange", pch = 18)
arrows(xi, mn.t  sd.t, xi, mn.t + sd.t,
code = 3, col = "pink", angle = 75, length = .1)
## boxplot on a matrix:
mat < cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
`5T` = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
boxplot(mat) # directly, calling boxplot.matrix()
## boxplot on a data frame:
df. < as.data.frame(mat)
par(las = 1) # all axis labels horizontal
boxplot(df., main = "boxplot(*, horizontal = TRUE)", horizontal = TRUE)
## Using 'at = ' and adding boxplots  example idea by Roger Bivand :
boxplot(len ~ dose, data = ToothGrowth,
boxwex = 0.25, at = 1:3  0.2,
subset = supp == "VC", col = "yellow",
main = "Guinea Pigs' Tooth Growth",
xlab = "Vitamin C dose mg",
ylab = "tooth length",
xlim = c(0.5, 3.5), ylim = c(0, 35), yaxs = "i")
boxplot(len ~ dose, data = ToothGrowth, add = TRUE,
boxwex = 0.25, at = 1:3 + 0.2,
subset = supp == "OJ", col = "orange")
legend(2, 9, c("Ascorbic acid", "Orange juice"),
fill = c("yellow", "orange"))
## more examples in help(bxp)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.