ggplot {visa} | R Documentation |
Create a new ggplot plot with a geom_line() layer from spectra data
Description
ggplot()
initializes a ggplot object. It can be used to
declare the input spectra object for a graphic and to optionally specify the
set of plot aesthetics intended to be common throughout all
subsequent layers unless specifically overridden.
Usage
## S3 method for class 'spectra'
ggplot(
data,
mapping = NULL,
...,
wl = NULL,
w.unit = "nm",
environment = parent.frame()
)
## S3 method for class 'cm'
ggplot(
data,
mapping = NULL,
...,
show.stat = TRUE,
environment = parent.frame()
)
Arguments
data |
Default spectra database to use for plot. If not a spectra database, the
methods used will be those defined in package |
mapping |
Default list of aesthetic mappings to use for plot. If not specified, in the case of spectra objects, a default mapping will be used. |
... |
Other arguments passed on to methods. Not currently used. |
wl |
numeric The wavelength vector. |
w.unit |
character The wavelength unit of the spectra. |
environment |
If an 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 |
show.stat |
A logic value. whether show the best R^2 and bands. |
Details
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.
Value
cm_plot |
Returns a ggplot object of correlation-matrix. |
Note
Current implementation does not merge default mapping with user supplied mapping. If user supplies a mapping, it is used as is. To add to the default mapping, aes() can be used by itself to compose the ggplot.
See Also
?ggpmisc::ggplot()
Examples
library(visa)
library(ggplot2)
ggplot.spectra(NSpec.DF)
library(visa)
data(NSpec.DF)
x <- NSpec.DF$N # nitrogen
S <- NSpec.DF$spectra[, seq(1, ncol(NSpec.DF$spectra), 5)] # resampled to 10 nm steps
cm <- cm.sr(S, x, cm.plot = FALSE)
ggplot.cm(cm)