Learn R Programming

analogue (version 0.14-0)

Stratiplot: Palaeoecological stratigraphic diagrams

Description

Draws palaeoecological stratigraphic diagrams of one or more variables as a function of depth/age, with the time dimension flowing from the bottom to the top of the y-axis, using the Lattice graphics package.

Usage

Stratiplot(x, ...)

## S3 method for class 'default': Stratiplot(x, y, type = "l", ylab = NULL, xlab = "", pages = 1, rev = TRUE, ylim, sort = c("none", "wa", "var"), svar = NULL, rev.sort = FALSE, strip = FALSE, topPad =6, varTypes = "relative", absoluteSize = 0.5, zoneNames = NULL, drawLegend = TRUE, na.action = "na.omit", labelAt = NULL, labelRot = 60, ...)

## S3 method for class 'formula': Stratiplot(formula, data, subset, na.action = "na.pass", type = "l", ylab = NULL, xlab = "", pages = 1, \dots)

Arguments

x
matrix-like object; the variables to be plotted.
y
numeric vector of depths/ages corresponding to rows in x. Length of y must be the same as nrow(x) or exactly equal to nrow(x) / ncol(x). See Details.
formula
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of plot specification are given under Details.
type
character; The type of plotting. Can be a vector. Note that not all Lattice types are supported and some new types are allowed. See panel.Stratiplot for further details
data
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables to plot. If not found in data, the variables are ta
subset
an optional vector specifying a subset of observations to be used in the fitting process.
na.action
a function which indicates what should happen when the data contain NAs. The default is "na.omit" for the default method, which strips NAs from the stacked data, whereas the default for the formula method
ylab, xlab
the x- and y-axis labels.
pages
numeric; the number of pages to draw the plot over. May be useful for data sets with many species.
rev
logical; should the y-axis limits be reversed
ylim
user supplied limits for the y-axis (time/depth). If not supplied, suitable limits will be determined from the data. As such, in general use ylim need not be supplied. If you choose to supply your own ylim values, not
sort
character; how should the variables (columns) of x be sorted on the plot. "wa" sorts by weighted averages of variable svar if not NULL or of y otherwise. The default when "
svar
vector; optional variable to sort columns of x by.
rev.sort
logical; should the sorting order be reversed.
strip
logical; Should panels have strips containing variable labels drawn on them? Default is FALSE, which labels each panel with a label resulting in a more familiar plot style.
topPad
numeric; additional padding for the top axis to accomodate long variable names. This is a temporary fudge until the actual space required can be automagically calculated from the variable names themselves. The currently gets most of the way th
varTypes
a character vector of length 1 or equal in length to the number of variables plotted. If length 1, the vector is expanded to the required length. Two values are allowed; i. "relative", and ii. "absolute". "relat
absoluteSize
numeric, length 1. This controls the width of panels for variables marked as "absolute", and is the proportion of the largest non-"absolute" panel.
zoneNames
character vector of labels, one per zone, with which to label the zone legend, if drawn (see argument drawLegend). See Details.
drawLegend
logical; should a legend for the zones
labelAt, labelRot
these control the placement and rotation, respectively, of the variable labels. labelAt is the coordinate at which the label is drawn; currently only one value is used so you can't place labels in different locations depending on
...
additional arguments passed to panel.Stratiplot and the underlying xyplot function.

Value

  • Returns a Lattice plot object of class "trellis".

Details

The function now includes preliminary code to handle both relative (proportional or percentage data) and absolute data types, and mixtures thereof. Mixtures can be specified by supplying a vector of types to varTypes, in the same order as the variables are drawn on the plot.

Plots can be specified symbolically using a formula. A typical model has the form Y ~ variables, where Y is either the core depths or sample ages/dates (to be plotted on the y-axis) and variables is a series of terms which specifies the variables to plot against Y. Terms should be specified with the form var1 + var2 + var3 to plot only those variables. Other, standard, notation for formulae apply, such as model formulae used in lm.

For the formula method the default for argument na.action is "na.pass", which results in any NA values being passed on to the plotting code. This allows for plotting of proxies that been measured on different levels of the stratigraphy. Should you wish to have NA removed from the data before plotting, use na.action = "na.omit", though do note this will remove all rows where any column/variable takes the value NA. The default Stratiplot method, which is used by the formula method for plotting, will strip any NA values from the data provided to it. This allows the function to correctly handle the situation where proxies are measured on different levels of the core and you are displaying the data using lines of polygons. If the NA were not dropped by Stratiplot.default, any NA values would show up as breaks in the line or polygon drawn for each panel.

In summary, the two methods have different defaults for na.action to allow them to handle proxies measured on different levels of the same core. This does mean that you can not use the formula interface and strip NA's at the Stratiplot.default level. If you need that level of control use Stratiplot.default directly by not providing a formula as argument x and by supplying data for the y-axis via argument y. See Examples for an illustration of these features.

Note that formula is not passed on to xyplot. Instead, the formula is parsed and evaluated within Stratiplot and an appropriate data structure formed to facilitate plotting via xyplot. As such, the special features of Lattice formulae cannot be used.

If zones are drawn on the stratigraphic plot, the zoneNames argument can be used to supply a set of names with which to label the zones using a legend. This legend is drawn on the right-hand side of the the straigraphic diagram if drawLegend = TRUE is supplied. The zoneNames must be supplied in stratigraphic order, as that is the order in which they are drawn in the legend. Whether this ordering is reversed or not will depend on the value of argument rev. It is up to the user to provide the labels in the correct order. Zones are specified by the zone boundaries (excluding the core sequence top and bottom), and as a result 1 more label is required than the number of zone boundaries supplied. If no zoneNames is not supplied, but a legend is requested, suitable names will be produced. If you do not wish to have any labelling at all, then set zoneNames = "" as this will get recycled to the correct length. See the Example section for an illustration of how this drawing zones works.

See Also

xyplot, panel.Stratiplot, panel.Loess.

Examples

Run this code
data(V12.122)
Depths <- as.numeric(rownames(V12.122))

(plt <- Stratiplot(Depths ~ O.univ + G.ruber + G.tenel + G.pacR,
                   data = V12.122,  type = c("h","l","g","smooth")))

## Order taxa by WA in depth --- ephasises change over time
(plt <- Stratiplot(Depths ~ O.univ + G.ruber + G.tenel + G.pacR,
                   data = V12.122, type = c("h"), sort = "wa"))

## Using the default interface
spp.want <- c("O.univ","G.ruber","G.tenel","G.pacR")
(plt <- Stratiplot(V12.122[, spp.want], y = Depths,
                   type = c("poly", "g")))

## Adding zones to a Stratigraphic plot
## Default labelling and draw zone legend
## Here we choose 4 arbitrary Depths as the zone boundaries
set.seed(123)
Zones <-sample(Depths, 4)
(plt <- Stratiplot(Depths ~ O.univ + G.ruber + G.tenel + G.pacR,
                   data = V12.122, type = c("poly","g"),
                   zones = Zones))

## As before, but supplying your own zone labels
zone.labs <- c("A","B","C","D","E")
(plt <- Stratiplot(Depths ~ O.univ + G.ruber + G.tenel + G.pacR,
                   data = V12.122, type = c("poly","g"),
                   zones = Zones, zoneNames = zone.labs))

## Suppress the drawing of the zone legend
(plt <- Stratiplot(Depths ~ O.univ + G.ruber + G.tenel + G.pacR,
                   data = V12.122, type = c("poly","g"),
                   zones = Zones, drawLegend = FALSE))

## Add zones and draw a legend, but do not label the zones
(plt <- Stratiplot(Depths ~ O.univ + G.ruber + G.tenel + G.pacR,
                   data = V12.122, type = c("poly","g"),
                   zones = Zones, zoneNames = ""))

## Show illustration of NA handling
set.seed(42)
dat <- data.frame(Depth = 1:20, LOI = runif(20), TC = NA)
dat <- within(dat, TC[sample(20, 10)] <- runif(10))
## default is 'na.action = "na.pass"'
(Stratiplot(Depth ~ LOI + TC, data = dat, type = c("l","p")))
## to remove rows with NA, use 'na.action = "na.omit"'
(Stratiplot(Depth ~ LOI + TC, data = dat, type = c("l","p"),
            na.action = "na.omit"))

## Example of two proxies measured on different levels of core
## (Here measurements on alternate levels)
set.seed(5)
dat2a <- data.frame(Depth = seq(1, by = 2, length = 20), LOI = runif(20))
dat2b <- data.frame(Depth = seq(0, by = 2, length = 20), TC = runif(20))
dat2 <- join(dat2a, dat2b, na.replace = FALSE, split = FALSE)
dat2 <- dat2[order(dat2$Depth), ]
head(dat2)

## Default is to allow NA through formula, but drop them when plotting
(Stratiplot(Depth ~ LOI + TC, data = dat2, type = c("l","p")))

## compare with this if we didn't suppress NA in default Stratiplot
## method (can't use formula interface for this yet
(Stratiplot(dat2[,-1], dat2[,1], type = c("l","p"),
            na.action = "na.pass"))
## Notice no lines are draw as there a no "sections" ithout missing
## levels. If you want/desire this behaviour then you can't use formula
## interface yet as there is no way to specify the na.action separately

Run the code above in your browser using DataLab