R: ggspectra: Extensions to 'ggplot2' for Radiation Spectra

ggspectra-package {ggspectra} | R Documentation

## ggspectra: Extensions to 'ggplot2' for Radiation Spectra

### Description

Additional annotations, and stats for plotting "light" spectra with 'ggplot2', together with specializations of ggplot() and plot() methods for spectral data stored in objects of the classes defined in package 'photobiology' and a plot() method for objects of class "waveband", also defined in package 'photobiology'.

### Details

Package 'ggspectra' provides a set of stats, geoms and methods extending packages 'ggplot2' and 'photobiology'. They easy the task of plotting radiation-related spectra and of annotating the resulting plots with labels and summary quantities derived from the spectral data.

Plot methods automate in many respects the plotting of spectral data. 'ggplot2' compatible statistics make the addition of labels or plotting of subject-area specific summaries possible as well as the addition of labels and wvaelength-based colour to plots easy. Available summaries are most of those relevant to photobiology. However, many of the functions in the package are more generaly useful for plotting UV, VIS and NIR spectra of light emission, transmittance, reflectance, absorptance, and responses.

The available summary qantities are both simple statistical summaries and response-weighted summaries. Simple derived quantities represent summaries of a given range of wavelengths, and can be expressed either in energy or photon based units. Derived _biologically effective_ quantities are used to quantify the effect of radiation on different organisms or processes within organisms. These effects can range from damage to perception of informational light signals. Additional features of spectra may be important and worthwhile annotating in plots. Of these, local maxima (peaks) and minima (valleys) present in spectral data can also be annotated with statistics made available by the 'ggspectra' package.

Package 'ggspectra' is useful solely for plotting spectral data as most functions depend on the x aesthetic being mapped to a variable containing wavelength values expressed in nanometres. It works well together with some other extensions to package 'ggplot2' such as packages 'ggrepel' and 'cowplot'.

This package is part of a suite of R packages for photobiological calculations described at the [r4photobiology](http://www.r4photobiology.info) web site.

### Note

This package makes use of the new features of 'ggplot2' 2.0.0 that make writing this kind of extensions really easy and is consequently not compatible with earlier versions of 'ggplot2'.

### Author(s)

Maintainer: Pedro J. Aphalo pedro.aphalo@helsinki.fi

Other contributors:

- Titta K. Kotilainen titta.kotilainen@helsinki.fi [contributor]

### References

`ggplot2` web site at http://ggplot2.org/
`ggplot2` source code at https://github.com/hadley/ggplot2
Function `multiplot` from http://www.cookbook-r.com/

### See Also

Useful links:

- http://www.r4photobiology.info

- https://bitbucket.org/aphalo/ggspectra

- Report bugs at https://bitbucket.org/aphalo/ggspectra

### Examples

    library(ggplot2)
    library(photobiology)
    library(photobiologyWavebands)

    ggplot(sun.spct) + geom_line() + stat_peaks(span = NULL)

    ggplot(sun.spct, aes(w.length, s.e.irrad)) + geom_line() +
      stat_peaks(span = 21, geom = "point", colour = "red") +
      stat_peaks(span = 51, geom = "text", colour = "red", vjust = -0.3,
                 label.fmt = "%3.0f nm")

    ggplot(polyester.spct) + geom_line()

    plot(sun.spct)

    plot(polyester.spct, UV_bands(), range = UV(),
         annotations = c("=", "segments", "labels"))

[Package ggspectra version 0.2.3 Index]