bxplot {rgr}R Documentation

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".
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 have the same x-axis scaling. However when used stand-alone the limits may be user-defined by setting xlim, see Note below.
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.

Note

Any less than detection limit values represented by negative values, or zeros or numeric codes representing blanks in the data vector, must be removed prior to executing this function, see ltdl.fix.df.

Any NAs in the data vector are removed prior to displaying the plot.

If the default selection for xlim is inappropriate it can be set, e.g., xlim = c(0, 200) or c(2, 200). If the defined limits lie within the observed data range a truncated plot will be displayed. If this occurs the number of data points omitted is displayed below the total number of observations.

If it is desired to prepare a display of data falling within a defined part of the actual data range, then either a data subset can be prepared externally using the appropriate R syntax, or xx may be defined in the function call as, for example, Cu[Cu < some.value] which would remove the influence of one or more outliers having values greater than some.value. In this case the number of data values displayed will be the number that are <some.value.

Author(s)

Robert G. Garrett

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

## 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)

[Package rgr version 1.0.3 Index]