Learn R Programming

aqp (version 1.18)

addBracket: Add Depth Brackets

Description

Add depth-wise brackets to an existing plot of a SoilProfileCollection object.

Usage

addBracket(x, label.cex=0.75,
tick.length = 0.05, arrow.length = 0.05, offset = -0.3, 
missing.bottom.depth = NULL, 
...)

Arguments

x

data.frame containing ID, `top`, `bottom`, and optionally `label` columns

label.cex

scaling factor for label font

tick.length

length of bracket "tick" mark

arrow.length

length of arrowhead

offset

numeric, length of left-hand offset from each profile

missing.bottom.depth

distance (in depth units) to extend brackets that are missing a lower depth (defaults to max depth of collection)

further arguments passed on to segments or arrows

Details

Additional examples can be found in this tutorial.

See Also

plotSPC

Examples

Run this code
# NOT RUN {
library(plyr)

# sample data
data(sp1)

# add color vector
sp1$soil_color <- with(sp1, munsell2rgb(hue, value, chroma))

# promote to SoilProfileCollection
depths(sp1) <- id ~ top + bottom

# plot profiles
plot(sp1)

# extract top/bottom depths associated with all A horizons
# return as a single data.frame / profile
f <- function(i) {
  h <- horizons(i)
  idx <- grep('^A', h$name)
  res <- data.frame(top=min(h$top[idx]), bottom=max(h$bottom[idx], na.rm=TRUE))
  return(res)
}

# apply function to each profile in sp1, result is a list
a <- profileApply(sp1, f, simplify=FALSE)
# convert list into data.frame
a <- ldply(a)
# set idname so that addBrackets can locate the correct profile
names(a)[1] <- idname(sp1)

# plot
plot(sp1)
# annotate with brackets
# note that plotting order is derived from the call to `plot(sp1)`
addBracket(a, col='red')

# brackets follow plotting order
plot(sp1, plot.order=length(sp1):1)
# annotate with brackets
# note that plotting order is derived from the call to `plot(sp1)`
addBracket(a, col='red')


# }

Run the code above in your browser using DataLab