Setup

library(ggplot2)
library(photobiology)
library(photobiologyWavebands)
library(ggspectra)
library(photobiologyPlants)
library(knitr)
opts_chunk$set(fig.path = 'figure/pos-', fig.align = 'center', fig.show = 'hold',
               fig.width = 7, fig.height = 4)
options(warnPartialMatchArgs = FALSE)

We bind two spectra, to later on demonstrate grouping.

two_suns.spct <- rbindspct(list(sun1 = sun.spct, sun2 = sun.spct * 2))

ggrepel

library(ggrepel)
ggplot(sun.spct) + geom_line() + 
  ylim(NA, 1) +
  stat_peaks(span = 21, geom = "text_repel", color = "red",
             nudge_y = rel(0.06), size = rel(3.5))
ggplot(sun.spct) + geom_line() + 
  stat_peaks(span = 21, geom = "label_repel", color = "white",
             nudge_y = 0.075, size = rel(2.5)) +
  ylim(NA, 1) +
  scale_fill_identity()
ggplot(two_suns.spct) + geom_line() + 
  stat_peaks(span = 21, geom = "label_repel", color = "white", 
             nudge_y = 0.15, size = rel(2)) +
  ylim(NA, 2) +
  scale_fill_identity() +
  facet_wrap(~spct.idx)

cowplot

library(cowplot)
theme_set(theme_cowplot(10))
plot(sun.spct, unit.out = "photon")
plot(sun.spct, w.band = VIS_bands(), unit.out = "photon")
theme_set(theme_cowplot(10))
p1 <- plot(sun.spct, unit.out = "photon")
p2 <- plot(yellow_gel.spct)
p3 <- plot(Solidago_altissima.mspct$lower_adax)
plot_grid(p1, p2, p3, ncol = 1, align = "V")
theme_set(theme_grey(10))
p1 <- plot(sun.spct, unit.out = "photon")
p2 <- plot(yellow_gel.spct)
p3 <- plot(Solidago_altissima.mspct$lower_adax)
plot_grid(p1, p2, p3, ncol = 1, align = "V")


aphalo/ggspectra documentation built on April 28, 2024, 5:22 a.m.