labelWithUnit | R Documentation |
labelWithUnit
creates a label with a unit, for graphical
display, e.g. by plot,section-method
.
The unit is enclosed in square brackets, although setting
options(oceUnitBracket="(")
will cause parentheses to be
used, instead. This function is intended mainly for use
within the package, and users should not rely on its behaviour being
unchangeable.
labelWithUnit(name, unit = NULL)
name |
character value naming a quantity. |
unit |
a list containing items |
If name
is in a standard list, then alterations are made as appropriate,
e.g. "SA"
or "Absolute Salinity"
yields an S with subscript A; "CT"
or
"Conservative Temperature"
yields an upper-case Theta, sigmaTheta
yields a sigma with subscript theta, sigma0
yields
sigma with subscript 0 (with similar for 1 through 4), "N2"
yields "N" with
superscript 2, and "pressure"
yields "p".
These basic hydrographic quantities have default units that will
be used if unit
is not supplied (see “Examples”).
In addition to the above, several chemical names are recognized, but no unit is guessed for them, because the oceanographic community lacks agreed-upon standards.
If name
is not recognized, then it is simply repeated in the
return value.
labelWithUnit
returns a language object, created with bquote()
,
that that may supplied as a text string to legend()
, mtext()
, text()
,
etc.
Dan Kelley
Other functions that create labels:
resizableLabel()
library(oce)
# 1. temperature has a predefined unit, but this can be overruled
labelWithUnit("temperature")
labelWithUnit(
"temperature",
list(unit = expression(m / s), scale = "erroneous")
)
# 2. phosphate lacks a predefined unit
labelWithUnit("phosphate")
data(section)
labelWithUnit(
"phosphate",
section[["station", 1]][["phosphateUnit"]]
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.