Draw Grid-Based Box Plots from Summaries

Share:

Description

gbxp draws grid-based box plots based on the given summaries in z.

Usage

1
2
3
4
5
6
7
8
gbxp(z, notch = FALSE, width = NULL, varwidth = FALSE, 
     outline = TRUE, notch.frac = 0.5, border = par("fg"), 
     pars = NULL, frame.plot = FALSE, horizontal = FALSE, 
     at = NULL, xaxis = FALSE, yaxis = FALSE, ...)
gboxplot(x, ..., width = NULL, varwidth = FALSE,
     notch = FALSE, outline = TRUE, notch.frac = 0.5, plot = TRUE, 
     border = par("fg"), pars = NULL, frame.plot = FALSE, 
     horizontal = FALSE, xaxis = FALSE, yaxis = FALSE, at = NULL)

Arguments

z

a list containing data summaries to be used in constructing the plots. These are usually the result of a call to boxplot, but can be generated in any fashion.

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). 'NA's are allowed in the data.

notch

if 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.

width

a vector giving the relative widths of the boxes making up the plot.

varwidth

if varwidth is TRUE, the boxes are drawn with widths proportional to the square-roots of the number of observations in the groups.

outline

if outline is not true, the outliers are not drawn.

notch.frac

numeric in (0,1). When notch=TRUE, the fraction of the box width that the notches should use.

border

character or numeric (vector), the colour of the box borders. Is recycled for multiple boxes. Is used as default for the boxcol, medcol, whiskcol, staplecol, and outcol options (see below).

frame.plot

logical, indicating if a frame (box) should be drawn; defaults to TRUE, unless axes = FALSE is specified.

horizontal

logical indicating if the boxplots should be horizontal; default FALSE means vertical boxes.

at

numeric vector giving the locations where the boxplots should be drawn, particularly when add = TRUE; defaults to 1:n where n is the number of boxes.

xaxis

logical. If TRUE x-axis is drawn.

yaxis

logical. If TRUE y-axis is drawn.

plot

logical for gboxplot. If TRUE a plot is drawn, else function boxplot is called.

pars,...

graphical parameters (etc) can be passed as arguments to this function, either as a list (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.

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.

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. The default depends on at and typically is 0.8.

staplewex, outwex: staple and outlier line width expansion, proportional to box width; both default to 0.5.

boxlty, boxlwd, boxcol, boxfill: box outline type, width, colour, and fill colour (which currently defaults to col and will in future default to par("bg")).

medlty, medlwd, medpch, medcex, medcol, medbg: median line type, line width, point character, point size expansion, colour, and background colour. The default medpch= NA suppresses the point, and medlty="blank" does so for the line. Note that medlwd defaults to 3x the default lwd.

whisklty, whisklwd, whiskcol: whisker line type (default: "dashed"), width, and colour.

staplelty, staplelwd, staplecol: staple (= end of whisker) line type, width, and colour.

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.

Author(s)

Original code by the R Core development team and Arni Magnusson. Modified by Ingo Voglhuber.

See Also

gbarplot, gmatplot, gpie, gsymbols, gbxp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
require(stats)
set.seed(753)
x <- split(rt(100, 4), gl(5,20))

grid.newpage()

gboxplot(x, yaxis=TRUE, frame.plot=TRUE)

grid.newpage()

gboxplot(x, notch = TRUE, pch = 4, boxfill=1:5)

grid.newpage()

gboxplot(x, notch = TRUE, boxfill= "lightblue",
  frame= FALSE, outl= FALSE,xaxis=TRUE,yaxis=TRUE, frame.plot=TRUE)

grid.newpage()

gboxplot(x, notch = TRUE, boxfill= "lightblue",
  border= 2:6, ylim = c(-4,4), pch = 22, bg = "green", log = "x")