Learn R Programming

aqp (version 1.4)

SoilProfileCollection-plotting-methods: Profile Plot

Description

Generate a simple diagram of a soil profile, with annotated horizon names.

Usage

plotSPC(x, color='soil_color', width=0.2, name='name', alt.label=NULL,
cex.names=0.5, cex.depth.axis=cex.names, cex.id=cex.names+(0.2*cex.names), print.id=TRUE, 
id.style='auto', plot.order=1:length(x), add=FALSE, scaling.factor=1, y.offset=0, n=length(x),
max.depth=max(x), n.depth.ticks=5, shrink=FALSE, shrink.cutoff=3, abbr=FALSE, 
abbr.cutoff=5, divide.hz=TRUE, hz.distinctness.offset=NULL, hz.distinctness.offset.col='black', 
hz.distinctness.offset.lty=2, axis.line.offset=-2.5, ...)

Arguments

x
a SoilProfileCollection object
color
the name of the column containing R-compatible color descriptions
width
scaling of profile widths
name
the name of the column containing the horizon designation
alt.label
the name of a column in @site used for seconary annotation
cex.names
character scaling applied to horizon names
cex.depth.axis
character scaling applied to depth scale
cex.id
character scaling applied to profile id
print.id
should the profile id be printed above each profile? (TRUE)
id.style
profile ID printing style: 'auto' (default) = simple heuristic used to select from: 'top' = centered above each profile, 'side' = 'along the top-left edge of profiles'
plot.order
a vector describing the order in which individual SoilProfile objects from the parent should be plotted
add
add to an existing figure
scaling.factor
vertical scaling of the profile heights
y.offset
vertical offset for top of profiles
n
integer describing amount of space along x-axis to allocate, defaults to length(x)
max.depth
suggested lower depth boundary of plot
n.depth.ticks
suggested number of ticks in depth scale
shrink
should long horizon names be shrunk by 80% ?
shrink.cutoff
character length defining long horizon names
abbr
should the profile ID be abbreviated?
abbr.cutoff
suggested minimum length for abbreviated IDs
divide.hz
should horizons be divided with a thin black line? (default is TRUE)
hz.distinctness.offset
column name containing vertical offsets used to depict horizon boundary distinctness (same units as profiles)
hz.distinctness.offset.col
color used to encode horizon distinctness (default is 'black')
hz.distinctness.offset.lty
line style used to encode horizon distinctness (default is 2)
axis.line.offset
horizonatal offset applied to depth axis (default is -2.5)
...
other arguments passed into lower level plotting functions

Value

  • A new plot of soil profiles is generated, or optionally added to an existing plot.

Details

Depth limits (max.depth) and number of depth ticks (n.depth.ticks) are *suggestions* to the pretty() function. You may have to tinker with both parameters to get what you want. The 'side' id.style is useful when plotting a large collection of profiles, and/or, when profile IDs are long.

References

http://casoilresource.lawr.ucdavis.edu/

See Also

SoilProfileCollection-class, pretty, hzDistinctnessCodeToOffset

Examples

Run this code
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, id.style='side')

# title, note line argument:
title('Sample Data 1', line=-1, cex.main=0.75)

# plot profiles without horizon-line divisions
plot(sp1, divide.hz=FALSE)

# plot profiles, using alternate profile ID label style
plot(sp1, id.style='side')

# add dashed lines illustrating horizon boundary distinctness
sp1$hzD <- hzDistinctnessCodeToOffset(sp1$bound_distinct)
plot(sp1, hz.distinctness.offset='hzD')

# plot horizon color according to some property
# RColorBrewer helps with nice colors
if(require(RColorBrewer)) {
  data(sp3)
  
  # setup colors
  cols <- rev(brewer.pal(8, 'Spectral'))
  cr <- colorRamp(cols)
  
  library(scales)
  # assign color based on clay content, rescaled to {0,1}
  sp3$soil_color <- rgb(cr(rescale(sp3$clay)), max=255)
  depths(sp3) <- id ~ top + bottom
  plot(sp3)
}

Run the code above in your browser using DataLab