ggplot()
initializes a ggplot object. It can be used to declare the
input spectral object for a graphic and to optionally specify the set of plot
aesthetics intended to be common throughout all subsequent layers unless
specifically overridden.
# S3 method for source_spct
ggplot(data, mapping = NULL, ..., range = NULL,
unit.out = getOption("photobiology.radiation.unit", default =
"energy"), environment = parent.frame())# S3 method for response_spct
ggplot(data, mapping = NULL, ..., range = NULL,
unit.out = getOption("photobiology.radiation.unit", default =
"energy"), environment = parent.frame())
# S3 method for filter_spct
ggplot(data, mapping = NULL, ..., range = NULL,
plot.qty = getOption("photobiology.filter.qty", default =
"transmittance"), environment = parent.frame())
# S3 method for reflector_spct
ggplot(data, mapping = NULL, ...,
range = NULL, plot.qty = NULL, environment = parent.frame())
# S3 method for cps_spct
ggplot(data, mapping = NULL, ..., range = NULL,
environment = parent.frame())
# S3 method for calibration_spct
ggplot(data, mapping = NULL, ...,
range = NULL, environment = parent.frame())
# S3 method for raw_spct
ggplot(data, mapping = NULL, ..., range = NULL,
environment = parent.frame())
# S3 method for object_spct
ggplot(data, mapping = NULL, ..., range = NULL,
plot.qty = getOption("photobiology.object.qty", default = "all"),
environment = parent.frame())
# S3 method for generic_mspct
ggplot(data, mapping = NULL, ..., range = NULL,
environment = parent.frame())
Default spectrum dataset to use for plot. If not a spectrum, the
methods used will be those defined in package ggplot2
. See
ggplot
. If not specified, must be suppled in each
layer added to the plot.
Default list of aesthetic mappings to use for plot. If not specified, in the case of spectral objects, a default mapping will be used.
Other arguments passed on to methods.
an R object on which range() returns a vector of length 2, with min annd max wavelengths (nm).
character string indicating type of units to use for
plotting spectral irradiance or spectral response, "photon"
or
"energy"
.
If a variable defined in the aesthetic mapping is not
found in the data, ggplot will look for it in this environment. It defaults
to using the environment in which ggplot()
is called.
character string one of "transmittance"
or
"absorbance"
for filter_spct
, and one of
"transmittance"
, "reflectance"
or "all"
for
object_spct
.
The method for collections of spectra
accepts arguments for the same parameters as the corresponding methods for
single spectra. Heterogeneous generic collections of spectra are not
supported. When plotting collections of spectra the factor spct.idx
contains as levels the names of the individual members of the collection,
and can be mapped to aesthetics or used for faceting.
ggplot()
is typically used to construct a plot incrementally, using
the +
operator to add layers to the existing ggplot object. This is
advantageous in that the code is explicit about which layers are added and
the order in which they are added. For complex graphics with multiple layers,
initialization with ggplot
is recommended.
We show seven common ways to invoke ggplot
for spectra and
collections of spectra:
ggplot(spct)
ggplot(spct, unit.out = <unit.to.use>)
ggplot(spct, plot.qty = <quantity.to.plot>)
ggplot(spct, range = <wavelength.range>)
ggplot(spct) + aes(<other aesthetics>)
ggplot(spct, aes(x, y, <other aesthetics>))
ggplot(spct, aes())
The first method is recommended if all layers use the same data and the same set of automatic default x and y aesthetics. The second, third and fourth use automatic default x and y aesthetics but first transform or trim the spectral data to be plotted. The fifth uses automatic default x and y aesthetics and adds mappings for other aesthetics. These patterns can be combined as needed. The sixth disables the use of a default automatic mapping, while the seventh delays the mapping of aesthetics and can be convenient when using different mappings for different geoms.
# NOT RUN {
library(photobiology)
library(ggplot2)
ggplot(sun.spct) + geom_line()
ggplot(sun.spct, unit.out = "photon") + geom_line()
ggplot(yellow_gel.spct) + geom_line()
ggplot(yellow_gel.spct, plot.qty = "absorbance") + geom_line()
ggplot(Ler_leaf.spct) + facet_grid(~variable) + geom_line()
ggplot(Ler_leaf.spct) + aes(linetype = variable) + geom_line()
# }
Run the code above in your browser using DataLab