forked from ncss-tech/aqp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddBracket.Rd
119 lines (93 loc) · 2.86 KB
/
addBracket.Rd
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/addBracket.R
\name{addBracket}
\alias{addBracket}
\title{Add Depth Brackets}
\usage{
addBracket(
x,
label.cex = 0.75,
tick.length = 0.05,
arrow.length = 0.05,
offset = -0.3,
missing.bottom.depth = NULL,
...
)
}
\arguments{
\item{x}{\code{data.frame} object containing \code{idname(x)}, \code{top}, \code{bottom}, and optionally \code{label} columns}
\item{label.cex}{scaling factor for label font}
\item{tick.length}{length of bracket "tick" mark}
\item{arrow.length}{length of arrowhead}
\item{offset}{left-hand offset from each profile}
\item{missing.bottom.depth}{distance (in depth units) to extend brackets that are missing a lower depth (defaults to max depth of collection)}
\item{...}{further arguments passed on to \code{segments} or \code{arrows}}
}
\description{
Add depth brackets to soil profile sketches.
}
\details{
\code{x} may contain multiple records per profile. Additional examples can be found in \href{http://ncss-tech.github.io/AQP/aqp/SPC-plotting-ideas.html}{this tutorial}.
}
\note{
This is a \code{low-level} plotting function: you must first plot a \code{SoilProfileCollection} object before using this function.
}
\examples{
# 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
par(mar = c(0, 0, 0, 1))
plotSPC(sp1, width = 0.3)
# extract min--max depths associated with all A horizons
# result is a single-row data.frame / profile
combinedBracket <- function(i) {
h <- horizons(i)
idn <- idname(i)
this.id <- h[[idn]][1]
idx <- grep('^A', h$name)
res <- data.frame(
id = this.id,
top = min(h$top[idx]),
bottom = max(h$bottom[idx], na.rm=TRUE)
)
names(res)[1] <- idn
return(res)
}
# return matching horizon top / bottom depths for A or C horizons
# result is a 0 or more row data.frame / profile
individualBrackets <- function(i) {
h <- horizons(i)
idn <- idname(i)
this.id <- h[[idn]][1]
idx <- grep('^A|^C', h$name)
res <- data.frame(
id = this.id,
top = h$top[idx],
bottom = h$bottom[idx]
)
names(res)[1] <- idn
return(res)
}
# combined brackets
b1 <- profileApply(sp1, combinedBracket, frameify = TRUE)
# individual brackets
b2 <- profileApply(sp1, individualBrackets, frameify = TRUE)
# plot in reverse order
plotSPC(sp1, plot.order = rev(1:length(sp1)), width = 0.25)
# note that plotting order is derived from the call to `plotSPC(sp1)`
addBracket(b1, col='red', offset = -0.35)
# plot in reverse order
plotSPC(sp1, plot.order = rev(1:length(sp1)), width = 0.25)
# note that plotting order is derived from the call to `plotSPC(sp1)`
addBracket(b2, col='red', offset = -0.35)
}
\seealso{
\code{\link{addDiagnosticBracket}, \link{plotSPC}}
}
\author{
D.E. Beaudette
}