plot.Spectra: Plots an object inheriting from the Spectra class

Description Usage Arguments Details Author(s) Examples

View source: R/plot-methods.R

Description

Plots an object inheriting from the Spectra class

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'Spectra'
 plot(x, gg=FALSE, gaps=TRUE, attr=NULL, ...)
## S4 method for signature 'Spectra'
 plot_summary(x, fun=mean, se=TRUE, ...)
## S4 method for signature 'Spectra'
 plot_stack(x)
## S4 method for signature 'Spectra'
 plot_offset(x, offset=1)

Arguments

x

an object of class "Spectra" or inheriting from this class

gg

if TRUE, uses the ggplot2 package to plot the data, if FALSE uses matplot from base graphics (much faster)

gaps

if TRUE, gaps in the spectra are not plotted

attr

attribute against which lines are coloured (only for gg = TRUE

fun

an aggregation function

se

if TRUE, plots the standard deviation around the summary spectra (computed by function as given by fun). If FALSE, does not plot dispersion information. If a function, uses this function instead of sd.

offset

Offset between spectra

...

options to be passed to matplot

Details

The philosophy of this plotting routine is to provide a "quick'n'dirty" way to plot your spectra collection. For advanced visualisations, the use of melt_spectra alongside with ggplot2 or lattice is encouraged.

Author(s)

Pierre Roudier pierre.roudier@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Loading example data
data(australia)
spectra(australia) <- sr_no ~ ... ~ 350:2500

# Default plotting method
plot(australia)

# Default plot using ggplot2
plot(australia, gg = TRUE)

# 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")

## Not run: 
# Example using colours given by ColorBrewer (http://colorbrewer2.org/)
library(RColorBrewer)
plot(australia, lty = 1, col = brewer.pal(n = 8, name = "Set2"))

## End(Not run)

# Using an attribute to group spectra

australia$fact <- sample(LETTERS[1:3], size = nrow(australia), replace = TRUE) # Generate some kind of factor
s <- aggregate_spectra(australia, fun = mean, id = 'fact')
plot(s, gg = TRUE, attr = 'fact')

inspectr documentation built on May 2, 2019, 5:45 p.m.