Generate wavelength, wavenumber, wave frequency, and energy per photon axis labels in SI units, using SI scale factors. Output can be selected as character, expression (R default devices) or LaTeX (for tikz device).
Usage
w_length_label(
unit.exponent = -9,
format = getOption("photobiology.math", default = "R.expression"),
label.text = axis_labels()[["w.length"]],
axis.symbols = getOption("ggspectra.axis.symbols", default = TRUE)
)
w_number_label(
unit.exponent = 0,
format = getOption("photobiology.math", default = "R.expression"),
label.text = axis_labels()[["w.number"]],
axis.symbols = getOption("ggspectra.axis.symbols", default = TRUE)
)
w_frequency_label(
unit.exponent = 9,
format = getOption("photobiology.math", default = "R.expression"),
label.text = axis_labels()[["freq"]],
axis.symbols = getOption("ggspectra.axis.symbols", default = TRUE)
)
w_energy_eV_label(
unit.exponent = 0,
format = getOption("photobiology.math", default = "R.expression"),
label.text = axis_labels()[["energy"]],
axis.symbols = getOption("ggspectra.axis.symbols", default = TRUE)
)
w_energy_J_label(
unit.exponent = -18,
format = getOption("photobiology.math", default = "R.expression"),
label.text = axis_labels()[["energy"]],
axis.symbols = getOption("ggspectra.axis.symbols", default = TRUE)
)
Arguments
- unit.exponent
integer The exponent in base 10 of the scale multiplier to use.
- format
character string, "R", "R.expresion", "R.character", or "LaTeX".
- label.text
character Textual portion of the labels.
- axis.symbols
logical If
TRUE
symbols of the quantities are added to thename
. Supported only byformat = "R.expression"
.
Details
By default labels consist in a textual name for the quantity, a
symbol separated by a comma and units with scale factor in parenthesis. The
textual names are by default in English but this default can be overridden
for example with translations to a different language. To change or
translate the default texts please see axis_labels_uk
. The
markup language used for the labels can be selected through a parameter
argument, with character strings ready to be parsed into R expressions
as default.
Wavelengths are assumed to be expressed in nanometres in the data. The
unit.exponent
corresponds to that desired for the tick labels
with the corresponding axis label automatically set to an SI scale
factor if possible, and otherwise shown as a power of 10.
These functions are used internally by x scales; see
sec_axis_w_number
and scale_x_wl_continuous
.
The scales and secondary axis functions should be used except when
defining new scale functions.
Examples
w_length_label()
#> "Wavelength, " ~ lambda ~ (plain("n") * plain(m))
w_length_label(axis.symbols = FALSE)
#> "Wavelength, " ~ (plain("n") * plain(m))
w_length_label(format = "R.expression")
#> "Wavelength, " ~ lambda ~ (plain("n") * plain(m))
w_length_label(format = "LaTeX")
#> [1] "Wavelength, $\\lambda$ (nm)"
w_number_label()
#> "Wavenumber, " ~ nu ~ (plain("") * plain(m)^{
#> -1
#> })
w_number_label(format = "R.expression")
#> "Wavenumber, " ~ nu ~ (plain("") * plain(m)^{
#> -1
#> })
w_frequency_label()
#> "Frequency, " ~ italic(f) ~ (plain("G") * plain(Hz))
w_frequency_label(format = "R.expression")
#> "Frequency, " ~ italic(f) ~ (plain("G") * plain(Hz))
w_energy_J_label()
#> "Energy per photon, " ~ italic(E) ~ (plain("a") * plain(J))
w_energy_eV_label()
#> "Energy per photon, " ~ italic(E) ~ (plain("") * plain(eV))