ggplot2 now has an official extension mechanism. This means that others can now easily create their own stats, geoms and positions, and provide them in other packages. This should allow the ggplot2 community to flourish, even as less development work happens in ggplot2 itself. This page showcases these extensions.


ggspectra extends ggplot2 with stats, geoms and annotations suitable for light spectra. It also defines ggplot() and plot() methods specialized for the classes defined in package photobiology for storing different types of spectral data.

# Example from

# We bind two spectra, to later on demonstrate grouping.
two_suns.spct <- rbindspct(list(sun1 = sun.spct, sun2 = sun.spct * 2))

# We change the default theme.

# ggplot() methods for spectra
ggplot(sun.spct) + geom_line()

# It is possible to the defaults by means of + and aes() as shown below.
ggplot(two_suns.spct) + aes(color = spct.idx) + geom_line()

# Several ggplot stats are defined by this package, for example:
ggplot(sun.spct) + geom_line() + 
  stat_peaks(shape = 21) + scale_fill_identity()