Learn R Programming

rgr (version 1.0.4)

bxplot: Plot a Horizontal Boxplot or Box-and-Whisker Plot

Description

Plots a single horizontal boxplot as part of the multi-panel display provided by function shape, the default is a Tukey boxplot, alternately a box-and-whisker plot may be displayed.

Usage

bxplot(xx, xlab = deparse(substitute(xx)), log = FALSE, ifbw = FALSE, 
	wend = 0.05, xlim = NULL, main = " ", colr = 8)

Arguments

xx
name of the variable to be plotted.
xlab
a title for the x-axis. It is often desirable to replace the default x-axis title of the input variable name text string with a more informative title, e.g., xlab = "Cu (mg/kg) in <2 mm="" o-horizon="" soil"<="" code="">.
log
if it is required to display the data with logarithmic (x-axis) scaling, set log = TRUE.
ifbw
the default is to plot a horizontal Tukey boxplot, if a box-and-whisker plot is required set ifbw = TRUE.
wend
if ifbw = TRUE the locations of the whisker-ends have to be defined. By default these are at the 5th and 95th percentiles of the data. Setting wend = 0.02 plots the whisker ends at the 2nd and 98th percentiles.
xlim
when used in the shape function, xlim is determined by gx.hist and used to ensure all four panels in shape
main
when used stand-alone a title may be added optionally above the plot by setting main, e.g., main = "Kola Project, 1995".
colr
by default the histogram and box are infilled in grey, colr = 8 . If no infill is required, set colr = 0. See display.lty for the range of available colours.

Details

The function can be used stand-alone, but as Tukey boxplots and box-and-whisker plots are usually used to compare the distributions of data subsets the functions tbplot (Tukey boxplots) and bwplot (box-and-whisker plots) are required for that purpose. When the boxplot is displayed on a logarithmically scaled x-axis, the data are log transformed prior to the computation of the positions of the fences used in the Tukey boxplot to identify near and far outliers, plotted as plusses and circles, respectively. In a box-and-whisker plot there are two special cases. When wend = 0 the whiskers extend to the observed minima and maxima that are not plotted with the plus symbol. When wend = 0.25 no whiskers or the data minimum and maximum are plotted, only the median and box representing the span of the middle 50 percent of the data are displayed.

References

Garrett, R.G., 1988. IDEAS - An Interactive Computer Graphics Tool to Assist the Exploration Geochemist. In Current Research Part F, Geological Survey of Canada Paper 88-1F, pp. 1-13 for a description of box-and-whisker plots.

See Also

shape, display.lty, ltdl.fix.df, remove.na

Examples

Run this code
## Make test data available
data(kola.o)
attach(kola.o)

## Display a simple boxplot
bxplot(Cu)


## Display a more appropriately labelled and scaled boxplot
bxplot(Cu, xlab = "Cu (mg/kg) in <2 mm O-horizon soil", log = TRUE)

## Display a box-and-whisker plot with whiskers ending at the 2nd and
## 98th percentiles
bxplot(Cu, xlab = "Cu (mg/kg) in <2 mm O-horizon soil", ifbw = TRUE, 
	wend = 0.02, log = TRUE)

## Detach test data
detach(kola.o)

Run the code above in your browser using DataLab