Plot difference between original (e.g., experimental) and reconstructed spectra. Function reconstructSp is used to reconstruct spectra, that are subtracted from original spectra afrterwards.

plot_spDiff(
  loadings,
  scores,
  sp,
  Title = "Difference between oginal and reconstructed spectra",
  color = if (".color" %in% names(sp$..)) sp$.color else "blue3",
  stacked = if ("ID" %in% names(sp$..)) sp$ID else NULL,
  spc.nmax = 2000,
  ...
)

Arguments

loadings

Components' spectra (loadings) as a hyperSpec object.

scores

Components' amplitudes (scores) as either a matrix or a hyperSpec object.

sp

hyperSpec object.

Title

The main title for the plot.

color

see par col. Might be a vector giving individual colors for the spectra. Default values: vector in sp$.color, if does not exist, "tan3" is used as a default color.

stacked

if not NULL, a "stacked" plot is produced. stacked may be TRUE to stack single spectra. A numeric or factor is be interpreted as giving the grouping, character is interpreted as the name of the extra data column that holds the groups. Default stacking is by sp$ID, and NULL if this variable is missing.

...

Other parameters to be passed to function plotspc.

Value

A plot of calculated difference between expected (original) and reconstructed spectra. (Drawn with R package graphics).

Note

Function plotspc is used to make a plot. R base plotting system annotations can be used to enhance the plot.

Author

Vilmantas Gegzna

Examples

plot_spDiff(Loadings2, Scores2[1:10,,], Spectra2[1:10,,], stacked = TRUE)
#> Warning: Function 'plotspc' is deprecated. 
#> Use function 'plot_spc' instead.