ggplot.hyperSpec: [!] 'ggplot' method for class 'hyperSpec'

Description Usage Arguments Value See Also Examples

View source: R/ggplot.hyperSpec.R

Description

Method to create a new ggplot object for class hyperSpec. More details in ggplot.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'hyperSpec'
ggplot(
  data,
  mapping = aes(),
  ...,
  wl.range = NULL,
  palette = NULL,
  format = "%g",
  environment
)

Arguments

data

A hyperSpec object

mapping

Default list of aesthetic mappings to be used for plotting. Default values are aes_string(x = ".wavelength", y = "spc", group = ".rownames"). Provided pameters update and modify this list. Other not specified parameters must be suppled in each layer added to the plot.

...

further arguments to be passed to function ggplot.

wl.range

wavelength ranges to plot. The ranges will be plotted as separate columns of facets. Examples in wl2i show how to select wavelength ranges of hyperSpec object
If wl.range is not NULL function facet_wl may be used to control facetting parameters. Otherwise standard ggplot2 functions, such as facet_grid or facet_wrap should be used if facetting is needed.

palette

[Expreimental!!!] Color palete for color and fill.

format

A string with format to be passed to sprintf. This string is used to format text in labels of wavelength intervals, when wl.range is specified. Default format is '%g'.

environment

Not used yet.

Value

A ggplot object. More details in package ggplot2.

See Also

qplotspc in package hyperSpec.
ggplot in package ggplot2.

Other spPlot functions for spectroscopy and hyperSpec: facet_wl(), ggLims(), gg_palette(), label_expr2text()

Other spPlot functions for ggplot2: facet_wl(), ggLims(), gg_palette(), nTick

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(spPlot)
library(spHelper)
data(Spectra2)

ggplot(Spectra2) + geom_line()
ggplot(Spectra2, aes(color=class)) + geom_line()
ggplot(Spectra2) + geom_line(color = "red", alpha = 0.1) + theme_bw()


ggplot(Spectra2, wl.range = c(min ~ 320, 500~600, 700 ~ max)) +
     geom_line(aes(color = gr))

Sp2 <- hyAdd_color(Spectra2, "gr", c("green","green3","skyblue"))
ggplot(Sp2, palette = TRUE) + geom_line()

ggplot(Sp2, aes(color = gr), palette = c("blue","gold4","tan")) +
    geom_line()

ggplot(Sp2) + geom_line(aes(color = I(.color)))


library(ggspectra)
ggplot(Sp2[1]) + stat_color(geom = "bar")+ scale_color_identity()

GegznaV/spPlot documentation built on April 29, 2020, 11:06 p.m.