Plot a Horizontal Boxplot or Box-and-Whisker Plot
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 (Garrett, 1988) may be displayed. Optionally the x-axis may be scaled logarithmically (base 10).
bxplot(xx, xlab = deparse(substitute(xx)), log = FALSE, ifbw = FALSE, wend = 0.05, xlim = NULL, main = "", ifn = TRUE, colr = 8, cex = 1, ...)
xx |
name of the variable to be plotted. |
xlab |
by default the character string for |
log |
to display the data with logarithmic (x-axis) scaling, set |
ifbw |
the default is to plot a horizontal Tukey boxplot, if a box-and-whisker plot is required set |
wend |
if |
xlim |
when used in the |
main |
when used stand-alone a title may be added optionally above the plot by setting |
ifn |
an internal ‘switch’ set |
colr |
by default the box is infilled in grey, |
cex |
by default the size of the text for data set size, N, is set to 80%, i.e. |
... |
further arguments to be passed to methods. For example, the size of the axis scale annotation can be change by setting |
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.
Any less than detection limit values represented by negative values, or zeros or numeric codes representing blanks in the data, must be removed prior to executing this function, see ltdl.fix.df
.
Any NA
s 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)
, the latter being appropriate for a logarithmically scaled plot, i.e. log = TRUE
. 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
.
Robert G. Garrett
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.
## 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 Kola 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 Kola O-horizon soil", ifbw = TRUE, wend = 0.02, log = TRUE) ## Detach test data detach(kola.o)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.