# NOT RUN {
library(photobiology)
library(ggplot2)
# ggplot() methods for spectral objects set a default mapping for x and y.
ggplot(sun.spct) + geom_line() +
stat_label_peaks(hjust = "left", span = 31, angle = 90, color = "red")
ggplot(sun.spct) + geom_line() +
stat_label_valleys(hjust = "right", span = 21, angle = 90, color = "blue")
# using 'ggrepel' to avoid overlaps
# too slow for CRAN checks
# }
# NOT RUN {
library(ggrepel)
library(photobiology)
ggplot(sun.spct) + geom_line() +
stat_peaks(span = 41, shape = 21, size = 3) +
stat_label_peaks(span = 41, geom = "label_repel", segment.colour = "red",
nudge_y = 0.12, label.fmt = "%3.0f nm") +
scale_fill_identity() +
scale_color_identity() +
expand_limits(y = c(NA, 1))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab