# ggplot() methods for spectral objects set a default mapping for x and y.
ggplot(sun.spct) +
geom_line() +
stat_peaks()
ggplot(sun.spct) +
geom_line() +
stat_valleys()
ggplot(sun.spct) +
geom_line() +
stat_peaks(span = 51, geom = "point", colour = "red") +
stat_peaks(span = 51, geom = "text", colour = "red",
vjust = -0.4, label.fmt = "%3.2f nm")
ggplot(sun.spct) +
geom_line() +
stat_peaks(span = 51, geom = "point", colour = "red", refine.wl = TRUE) +
stat_peaks(span = 51, geom = "text", colour = "red",
vjust = -0.4, label.fmt = "%3.2f nm",
refine.wl = TRUE)
ggplot(sun.spct) +
geom_line() +
stat_peaks(span = 51, geom = "point", colour = "red", refine.wl = TRUE) +
stat_peaks(mapping = aes(fill = after_stat(wl.colour), color = after_stat(BW.colour)),
span = 51, geom = "label",
size = 3, vjust = -0.2, label.fmt = "%.3g nm",
refine.wl = TRUE) +
stat_valleys(span = 71, geom = "point", colour = "blue", refine.wl = TRUE) +
stat_valleys(mapping = aes(fill = after_stat(wl.colour), color = after_stat(BW.colour)),
span = 71, geom = "label",
size = 3, vjust = 1.2, label.fmt = "%.3g nm",
refine.wl = TRUE) +
expand_limits(y = 0.85) + # make room for label
scale_fill_identity() +
scale_color_identity()
Run the code above in your browser using DataLab