
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",
...)
## S3 method for class 'formula':
Stratiplot(formula, data, subset,
na.action = "na.pass", type = "l",
ylab = NULL, xlab = "", pages = 1, \dots)
x
. Length of y
must be the same as nrow(x)
or
exactly equal to nrow(x) / ncol(x)
. See Details."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
panel.Stratiplot
for further
detailsas.data.frame
to a data frame) containing
the variables to plot. If not found in data
, the variables
are taNA
s. The default is "na.omit"
for the
default method, which strips NA
s from the stacked data,
whereas the default for the formula methodylim
need not be supplied. If you choose to
supply your own ylim
values, notx
be sorted on the plot. "wa"
sorts by weighted averages
of variable svar
if not NULL
or of y
otherwise. The default when "
x
by.FALSE
, which labels each
panel with a label resulting in a more familiar plot style."relative"
, and ii. "absolute"
. "relat
"absolute"
, and is the
proportion of the largest non-"absolute"
panel.drawLegend
). See Details.panel.Stratiplot
and the underlying
xyplot
function."trellis"
.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
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.
xyplot
,
panel.Stratiplot
, panel.Loess
.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