Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plotScores3D

3D PCA Score Plot for a Spectra Object


Description

Creates a basic 3D plot of PCA scores from the analysis of a Spectra object, color coded according the to scheme stored in the object.

Usage

plotScores3D(
  spectra,
  pca,
  pcs = c(1:3),
  ellipse = TRUE,
  rob = FALSE,
  cl = 0.95,
  frac.pts.used = 0.8,
  view = list(y = 34, x = 10, z = 0),
  tol = 0.01,
  use.sym = FALSE,
  ...
)

Arguments

spectra

An object of S3 class Spectra.

pca

An object of class prcomp, modified to include a list element called $method, a character string describing the pre-processing carried out and the type of PCA performed (it appears on the plot). This is automatically provided if ChemoSpec functions c_pcaSpectra or r_pcaSpectra were used to create pca.

pcs

A vector of three integers specifying the PCA scores to plot.

ellipse

Logical indicating if confidence ellipses should be drawn.

rob

Logical; if ellipse = TRUE, indicates that robust confidence ellipses should be drawn. If FALSE, classical confidence ellipses are drawn.

cl

A number indicating the confidence interval for the ellipse.

frac.pts.used

If ellipse = TRUE and rob = TRUE, a number indicating the fraction of the data points to be considered "good" and thus used to compute the robust confidence ellipse.

view

A list of viewing transformations to be applied to the data. May contain values for x, y and z axes; keep in mind that the order of the transformations is important. For example, specifying view = list(x = 45, y = 10) produces a different view than view = list(y = 10, x = 45). The list may be as along as you like - the series of transformations representing an accumulation of tweaks to achieve the desired view.

tol

Quantile to be used to label extreme data points. Currently not used - need to fix the code!

use.sym

logical; if true, the color scheme is change to black and symbols are used for plotting.

...

Other parameters to be passed downstream.

Value

None. Side effect is a plot.

Author(s)

Bryan A. Hanson, DePauw University.

See Also

For a 2D plot of the scores, see plotScores. For interactive 3D plots, use plotScoresRGL. Additional documentation at https://bryanhanson.github.io/ChemoSpec/

Examples

data(metMUD1)
pca <- c_pcaSpectra(metMUD1, choice = "noscale")
plotScores3D(metMUD1, pca, main = "metMUD1 NMR Spectra")

ChemoSpec

Exploratory Chemometrics for Spectroscopy

v5.3.11
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>), Mike Bostock [cph, ctb] (author of the d3.js library used by plotSpectraJS, http://d3js.org), Matt Keinsley [ctb] (author of initial AOV-PCA code)
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.