Learn R Programming

rioja (version 0.9-6)

strat.plot: Plot a stratigraphic diagram

Description

Plots a diagram of multiple biological, physical or chemical parameters agains depth or time, as used in geology & palaeoecology.

Usage

strat.plot (d, yvar = NULL, scale.percent = FALSE, 
    graph.widths=1, minmax=NULL, 
    scale.minmax = TRUE, xLeft = 0.07, xRight = 1, 
    yBottom = 0.07, yTop = 0.8, title = "", cex.title=1.8, 
    y.axis=TRUE, min.width = 5, ylim = NULL, y.rev = FALSE, 
    y.tks=NULL, ylabel = "", cex.ylabel=1, cex.yaxis=1, 
    xSpace = 0.01, x.pc.inc=10, x.pc.lab=TRUE, x.pc.omit0=TRUE,
    wa.order = "none", plot.line = TRUE,
    col.line = "black", lwd.line = 1, plot.bar = TRUE, 
    lwd.bar = 1, col.bar = "grey", sep.bar = FALSE, 
    plot.poly = FALSE, col.poly = "grey", col.poly.line = NA, 
    lwd.poly = 1, plot.symb = FALSE, symb.pch=19, symb.cex=1,
    x.names=NULL, cex.xlabel = 1.1, srt.xlabel=90, 
    mgp=NULL, cex.axis=.8, clust = NULL, clust.width=0.1, 
    orig.fig=NULL, add.smooth=FALSE, col.smooth="red", smooth.span=0.1, lwd.smooth=1, 
    exag=FALSE, exag.mult=5, col.exag="grey90", exag.alpha=0.2, add=FALSE, ...)
    
addZone (x, upper, lower=NULL, ...)

addClustZone(x, clust, nZone, ...)

Arguments

d
a matrix or data frame of variables to plot.
yvar
a vector of depths or ages to use for the y-axis (defaults to sample number).
scale.percent
logical to scale x-axes for (biological) percentage data.
graph.widths
a vector of relative widths for each curve, used if scale.percent=FALSE.
minmax
2 * nvar matrix of min and max values to scale each curve if scale.percent=FALSE.
scale.minmax
logical to show only min and max values on x-axes (to avoid label crowding).
xLeft, xRight, yBottom, yTop
x, y position of plot on page, in relative units.
title
main title for plot.
x.names
character vector of names for each graph, of same length as ncol(d).
cex.title
size of label for title.
y.axis
logical to control drawing to left-hand y-axis scale. Defaults to TRUE.
min.width
minimum upper value of x-axis when scaled for percent data.
ylim
numeric vector of 2 values to control limist of y-axis. Defaults to data range.
y.rev
logical to reverse y-axis. Defaults to FALSE.
y.tks
numerical vector listing values of y-axis ticks / labels.
ylabel
label for y-axis.
cex.ylabel, cex.yaxis
text size for y-axis labels and values.
xSpace
space between graphs, in relative units.
x.pc.inc
increment for x-axis values when scale.percent is TRUE.
x.pc.lab
logical to control drawing of x-axis values when scale.percent is TRUE.
x.pc.omit0
logical to omit initial zero x-axis label when scale.percent is TRUE.
wa.order
"none", "topleft" or "bottomleft", to sort variables according to the weighted average with y.
plot.line, plot.poly, plot.bar
logical flags to plot graphs as lines, silhouettes, or bars.
col.line, col.poly.line
colour of lines and silhouette outlines. Can be a single colour or a vector of colours, one for each graph.
col.poly
silhouette fill colour. Can be a single colour or a vector of colours, one for each graph.
lwd.line, lwd.poly, lwd.bar
line widths for line, silhouette or bar graphs.
col.bar
colour of bars in a bar graph. col.bar can be a vector to specify colours of individual bars or graphs.
sep.bar
If true, colours in col.bar are applied to individual bars, otherwise individual graphs.
cex.xlabel
size of label for variable names.
srt.xlabel
rotation angle for variable names.
plot.symb, symb.pch, symb.cex
logical for plotting symbols and symbol type / size.
add.smooth
logical for adding loess smooth to a curve. Can be a single value or a vector to add smooths to individual curves.
col.smooth, lwd.smooth
colour / line width of loess smooth.
smooth.span
span for the loess smooth.
exag
logical to add exaggerated curves when plot.poly=TRUE. Can be a single value or a vector to add exaggeration to individual curves.
exag.mult
multiplier for exaggerated curves. Can be a single value or a vector to control exaggeration to individual curves.
col.exag
colour for exaggerated curves. Can be a single value, a vector to control colour of individual curves, or "auto" for transparent version of main curve.
exag.alpha
alpha channel for transparent exaggerated curves when col.exag="auto".
mgp
value of mgp for x-axes. See par for details.
cex.axis
text size for x-axis labels. See par for details.
clust
an constrained classification object of class chclust to add to plot.
clust.width
width of dendrogram to add to right of plot, in relative units.
orig.fig
fig values to specify area of window in which to place diagram. See par for details. Defaults to whole window.
add
logical to contol drawing of new page. See par for details. Defaults to FALSE in which a call to strat.plot will start a new diagram. Set to TRUE to add a diagram to an existing plot.
x
a stratigraphic diagram object produced by strat.plot.
upper, lower
upper and (optional) lower limits of a zone to add to an existing stratigraphic diagram.
nZone
number of zones to draw.
...
further graphical arguments.

Value

  • Returns a list containing the following objects:
  • boxVector of 4 values giving the coordinates of the left, right, bottom and top of the plotting area, in relative units.
  • usrRanges of the plotting area, in data units.
  • yvarVariable used for the y-axis.
  • ylimLimits of the y-axis.

Details

strat.plot plots a series of variables in a stratigraphic diagram. Diagrams can be plotted as line graphs and / or bar charts. Samples are plotted on the y-axis by sample number by default but may be plotted against sample age otr depth by specifying a variable for yvar. Margins of the plotting area can be changed using xLeft, xRight, yBottom and yTop. A dendrogram produced by chclust can be added to the right of the diagram. The function addZone can be used to add a horizontal line or box to an existing plot, and addClustZone will add a specified number of zones from a dendrogram (see examples). The function uses fig to split the screen and may be incompatible with par(mfrow) and split.screen.

See Also

chclust.

Examples

Run this code
library(vegan) ## decorana
data(RLGH)
# create appropriately sized graphics window
windows(width=12, height=7) # quartz() on Mac, X11 on linux
# remove less abundant taxa
mx <- apply(RLGH$spec, 2, max)
spec <- RLGH$spec[, mx > 3]
depth <- RLGH$depths$Depth
#basic stratigraphic plot
strat.plot(spec, y.rev=TRUE)
#scale for percentage data
strat.plot(spec, y.rev=TRUE, scale.percent=TRUE)
# plot by sample depth
strat.plot(spec, yvar = depth, y.rev=TRUE, scale.percent=TRUE,
title="Round Loch of Glenhead", ylabel="Depth (cm)")
# add a dendromgram from constrained cluster analysis
diss <- dist(sqrt(RLGH$spec/100)^2)
clust <- chclust(diss, method="coniss")
# broken stick model suggest 3 significant zones
bstick(clust)
x <- strat.plot(spec, yvar = depth, y.rev=TRUE,
scale.percent=TRUE, title="Round Loch of Glenhead", ylabel="Depth (cm)",
clust=clust)
# add zones
addClustZone(x, clust, 3, col="red")
# use fig to contol diagram size and position
x <- strat.plot(spec, xRight = 0.7, yvar = depth, y.rev=TRUE,
scale.percent=TRUE, title="Round Loch of Glenhead", ylabel="Depth (cm)")
# add curves for first two DCA components of diatom data
dca <- decorana(spec, iweigh=1)
sc <- scores(dca, display="sites", choices=1:2)
strat.plot(sc, xLeft = 0.7, yvar = depth, y.rev=TRUE, xRight=0.99,
y.axis=FALSE, clust=clust, clust.width=0.08, add=TRUE)

# Pollen diagram using built-in Abernethy Forest dataset

data(aber)
depth <- aber$ages$Age
spec <- aber$spec

# basic silhouette plot
strat.plot(spec, yvar = depth, y.rev=TRUE, scale.percent=TRUE, ylabel="Depth (cm)", 
plot.poly=TRUE, col.poly="darkgreen", col.poly.line=NA)

# now with horizontal lines at sample positions
strat.plot(spec, yvar = depth, y.rev=TRUE, scale.percent=TRUE, ylabel="Depth (cm)", 
plot.poly=TRUE, col.poly="darkgreen", plot.bar="Full", col.poly.line=NA)

# add exaggerated curves
strat.plot(spec, yvar = depth, y.rev=TRUE, scale.percent=TRUE, ylabel="Depth (cm)", 
plot.poly=TRUE, col.poly="darkgreen", plot.bar="Full", col.poly.line=NA, exag=TRUE)

# use different colours for trees
xx <- 1:ncol(spec)
cc <- ifelse(xx < 8, "darkgreen", "darkred")
strat.plot(spec, yvar = depth, y.rev=TRUE, scale.percent=TRUE, ylabel="Depth (cm)", 
plot.poly=TRUE, col.poly=cc, plot.bar="Full", col.poly.line=NA, exag=TRUE, col.exag="auto")

Run the code above in your browser using DataLab