##
## Simple Example
##
# using default arguments to plotSPC()
# load sample data
data(sp3)
data(sp4)
# promote to SoilProfileCollection
depths(sp3) <- id ~ top + bottom
depths(sp4) <- id ~ top + bottom
# combine into a list
spc.list <- list(sp3, sp4)
# argument list
arg.list <- list(
list(name='name', id.style='top'),
list(name='name', id.style='side')
)
# plot multiple SPC objects,
# with list of named arguments for each call to plotSPC
par(mar=c(1,1,3,3))
plotMultipleSPC(
spc.list,
group.labels = c('Collection 1', 'Collection 2'),
args = arg.list,
bracket.base.depth = 120, label.cex = 1
)
# specify a different max.depth
plotMultipleSPC(
spc.list,
group.labels = c('Collection 1', 'Collection 2'),
args = arg.list,
bracket.base.depth = 120, label.cex = 1,
max.depth = 250
)
##
## Merged Legend Example
##
# merged legend based on hz attribute 'clay'
# reset sample data
data(sp3)
data(sp4)
# promote to SoilProfileCollection
depths(sp3) <- id ~ top + bottom
depths(sp4) <- id ~ top + bottom
# combine into a list
spc.list <- list(sp3, sp4)
# argument list
arg.list <- list(
list(name='name', id.style='top'),
list(name='name', id.style='side')
)
par(mar=c(1,1,3,3))
plotMultipleSPC(
spc.list,
group.labels = c('Collection 1', 'Collection 2'),
args = arg.list,
label.cex = 1,
merged.legend = 'clay', merged.legend.title = 'Clay (%)'
)
##
## Complex Merged Legend Example
##
# create a merged legend from "clay" in sp4 and jacobs2000
# use "soil_color" from sp3
# reset sample data
data(sp3)
data(sp4)
data(jacobs2000)
# promote to SoilProfileCollection
depths(sp3) <- id ~ top + bottom
depths(sp4) <- id ~ top + bottom
# remove 'clay' column from sp3
sp3$clay <- NULL
# combine into a list
spc.list <- list(sp3, sp4, jacobs2000)
# try some variations on the default arguments
# `clay` is missing in the first SPC, safe to specify another column for colors
arg.list <- list(
list(color = 'soil_color', id.style='top', name = NA, width = 0.3, hz.depths = TRUE),
list(name='name', id.style='side', name.style = 'center-center'),
list(name='name', id.style='side', name.style = 'left-center', hz.depths = TRUE)
)
par(mar=c(1,1,3,3))
plotMultipleSPC(
spc.list,
group.labels = c('sp3', 'sp4', 'jacobs2000'),
label.offset = 3,
args = arg.list,
merged.legend = 'clay', merged.legend.title = 'Clay (%)',
depth.axis = list(line = 0)
)
Run the code above in your browser using DataLab