addBracket: Add Depth Brackets

Description Usage Arguments Details Note Author(s) See Also Examples

View source: R/addBracket.R

Description

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

Usage

1
2
3
4
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.

Note

This is a 'low-level' plotting function: you must first plot a SoilProfileCollection object before using this function.

Author(s)

D.E. Beaudette

See Also

plotSPC

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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')

ncss-tech/aqp documentation built on April 4, 2020, 8:11 a.m.