The goal of ‘ggspectra’ is to make it easy to plot radiation spectra and similar data, such and transmittance, absorbance and reflectance spectra, producing fully annotated publication- and presentation-ready plots. It is an extension to packages ‘ggplot2’ and ‘photobiology’, and part of the ‘r4phototbiology’ suite.

Package ‘ggspectra’ provides stats, geoms, scales and functions to be used for plotting radiation-related spectra and annotating the plots with quantities derived from spectral data. All summary quantities implemented in ‘photobiology’ can be used for annotations including biologically effective irradiances and exposures.

Please, see the web site r4photobiology for details on other packages available as part of the suite, and on how to install them.


This is a basic example which shows plotting using the most automatic approach.


This second example uses the grammar of graphics approach, as implemented in ‘ggplot2’.

ggplot(sun.spct) +
  geom_spct() +
  scale_y_s.q.irrad_continuous() +
  scale_x_wl_continuous(sec.axis = sec_axis_w_number()) +


Installation of the most recent stable version from CRAN:


Installation of the current unstable version from Bitbucket:

# install.packages("devtools")


HTML documentation is available at (, including a User Guide.

News on updates to the different packages of the ‘r4photobiology’ suite are regularly posted at (

Two articles introduce the basic ideas behind the design of the suite and its use: Aphalo P. J. (2015) ( and Aphalo P. J. (2016) (

A book is under preparation, and the draft is currently available at ( The book conatins many examples of plots created with ‘ggspectra’.

A handbook written before the suite was developed contains useful information on the quantification and manipulation of ultraviolet and visible radiation: Aphalo, P. J., Albert, A., Björn, L. O., McLeod, A. R., Robson, T. M., & Rosenqvist, E. (Eds.) (2012) Beyond the Visible: A handbook of best practice in plant UV photobiology (1st ed., p. xxx + 174). Helsinki: University of Helsinki, Department of Biosciences, Division of Plant Biology. ISBN 978-952-10-8363-1 (PDF), 978-952-10-8362-4 (paperback). PDF file available from (


Pull requests, bug reports, and feature requests are welcome at (


If you use this package to produce scientific or commercial publications, please cite according to:

#> To cite package 'ggspectra' in publications, please use:
#>   Aphalo, Pedro J. (2015) The r4photobiology suite. UV4Plants
#>   Bulletin, 2015:1, 21-29. DOI:10.19232/uv4pb.2015.1.14
#> A BibTeX entry for LaTeX users is
#>   @Article{,
#>     author = {Pedro J. Aphalo},
#>     title = {The r4photobiology suite},
#>     journal = {UV4Plants Bulletin},
#>     volume = {2015},
#>     number = {1},
#>     pages = {21-29},
#>     year = {2015},
#>     doi = {10.19232/uv4pb.2015.1.14},
#>   }


© 2015-2018 Pedro J. Aphalo ( Released under the GPL, version 2 or greater. This software carries no warranty of any kind.