autoplot.cps_spct {ggspectra} | R Documentation |
Create a complete ggplot for detector-counts per second spectra.
Description
This function returns a ggplot object with an annotated plot of a response_spct object.
Usage
## S3 method for class 'cps_spct'
autoplot(
object,
...,
w.band = getOption("photobiology.plot.bands", default = list(UVC(), UVB(), UVA(),
PhR())),
range = NULL,
norm = "skip",
unit.out = NULL,
pc.out = FALSE,
label.qty = "mean",
span = NULL,
wls.target = "HM",
annotations = NULL,
geom = "line",
time.format = "",
tz = "UTC",
text.size = 2.5,
idfactor = NULL,
facets = FALSE,
ylim = c(NA, NA),
object.label = deparse(substitute(object)),
na.rm = TRUE
)
## S3 method for class 'cps_mspct'
autoplot(
object,
...,
range = NULL,
norm = "skip",
unit.out = NULL,
pc.out = FALSE,
idfactor = TRUE,
facets = FALSE,
plot.data = "as.is",
object.label = deparse(substitute(object)),
na.rm = TRUE
)
Arguments
object |
a cps_spct object. |
... |
in the case of collections of spectra, additional arguments passed to the plot methods for individual spectra, otherwise currently ignored. |
w.band |
a single waveband object or a list of waveband objects. |
range |
an R object on which range() returns a vector of length 2, with min annd max wavelengths (nm). |
norm |
numeric normalization wavelength (nm) or character string
|
unit.out |
character IGNORED. |
pc.out |
logical, if TRUE use percent instead of fraction of one for normalized spectral data. |
label.qty |
character string giving the type of summary quantity to use for labels, one of "mean", "total", "contribution", and "relative". |
span |
a peak is defined as an element in a sequence which is greater than all other elements within a window of width span centered at that element. |
wls.target |
numeric vector indicating the spectral quantity values for
which wavelengths are to be searched and interpolated if need. The
|
annotations |
a character vector ("summaries" is ignored). For details please see sections Plot Annotations and Title Annotations. |
geom |
character The name of a ggplot geometry, currently only
|
time.format |
character Format as accepted by |
tz |
character Time zone to use for title and/or subtitle. |
text.size |
numeric size of text in the plot decorations. |
idfactor |
character Name of an index column in data holding a
|
facets |
logical or integer Indicating if facets are to be created for
the levels of |
ylim |
numeric y axis limits, |
object.label |
character The name of the object being plotted. |
na.rm |
logical. |
plot.data |
character Data to plot. Default is "as.is" plotting one line per spectrum. When passing "mean", "median", "sum", "prod", "var", "sd", "se" as argument all the spectra must contain data at the same wavelength values. |
Details
Note that scales are expanded so as to make space for the annotations. The object returned is a ggplot objects, and can be further manipulated.
Value
a ggplot
object.
Plot Annotations
The recognized annotation names are: "summaries"
, "peaks"
,
"peak.labels"
, "valleys"
, "valley.labels"
,
"wls"
, "wls.labels"
, "colour.guide"
,
"color.guide"
, "boxes"
, "segments"
, "labels"
.
In addition, "+"
is interpreted as a request to add to the already
present default annotations, "-"
as request to remove annotations
and "="
or missing"+"
and "-"
as a request to reset
annotations to those requested. If used, "+"
, "-"
or
"="
must be the first member of a character vector, and followed by
one or more of the names given above. To simultaneously add and remove
annotations one can pass a list
containing character
vectors
each assembled as described. The vectors are applied in the order they
appear in the list. To disable all annotations pass ""
or
c("=", "")
as argument. Adding a variation of an annotation already
present, replaces the existing one automatically: e.g., adding
"peak.labels"
replaces"peaks"
if present.
Title Annotations
metadata retrieved from object object
is
paased to ggplot2::ggtitle()
as arguments for title
,
subtitle
and caption
. The specification for the title is
passed as argument to annotations
, and consists in the keyword
title
with optional modifiers selecting the kind of metatdata to
use, separated by colons. Up to three keywords separated by colons are
accepted, and correspond to title, subtitle and caption. The recognized
keywords are: "objt"
, "class"
, "what"
, "when"
,
"where"
, "how"
, "inst.name"
, "inst.sn"
,
"comment"
and "none"
are recognized as modifiers to
"title"
; "none"
is a placeholder. Default is
"title:objt"
or no title depending on the context.
See Also
normalize
,
cps_spct
,
waveband
,
photobiologyWavebands-package
and
autoplot
Other autoplot methods:
autoplot.calibration_spct()
,
autoplot.filter_spct()
,
autoplot.object_spct()
,
autoplot.raw_spct()
,
autoplot.reflector_spct()
,
autoplot.response_spct()
,
autoplot.source_spct()
,
autoplot.waveband()
,
set_annotations_default()
Examples
autoplot(white_led.cps_spct)
autoplot(white_led.cps_spct, geom = "spct")
autoplot(white_led.cps_spct, norm = "max")
two_leds.mspct <-
cps_mspct(list("LED 1" = white_led.cps_spct,
"LED 2" = white_led.cps_spct / 2))
autoplot(two_leds.mspct)
autoplot(two_leds.mspct, idfactor = "Spectra")
autoplot(two_leds.mspct, plot.data = "mean")