# NOT RUN {
# Loading example data
data(australia)
spectra(australia) <- sr_no ~ ... ~ 350:2500
# Default plotting method
plot(australia[1:5,])
# Default plot using ggplot2
plot(australia[1:5,], gg = TRUE)
# }
# NOT RUN {
# Managing gaps in the spectra
s <- cut(australia, wl =c(-1*450:500, -1*1800:2050))
plot(s, gaps = TRUE)
plot(s, gaps = FALSE)
# passing various options to matplot
plot(
australia,
lty = 1:5,
col = 'blue',
xlab = 'foo', ylab = 'bar',
ylim = c(0.4,0.6),
main = 'my plot'
)
# Using colour ramps
plot(
australia,
lty = 1,
col = rainbow(10),
main = "It is possible to create really ugly visualisations"
)
# Example using colours given by ColorBrewer (http://colorbrewer2.org/)
library(RColorBrewer)
plot(australia, lty = 1, col = brewer.pal(n = 8, name = "Set2"))
# Using an attribute to group spectra
# Generate some kind of factor
australia$fact <- sample(
LETTERS[1:3],
size = nrow(australia),
replace = TRUE
)
s <- aggregate_spectra(australia, fun = mean, id = 'fact')
plot(s, gg = TRUE, attr = 'fact')
# }
Run the code above in your browser using DataLab