Learn R Programming

visa (version 1.0.0)

ggplot.cm: Create a ggplot Plot from Correlation Coefficients (Deprecated)

Description

**Deprecated:** This function is deprecated and will be removed in a future release. Please use plt.2dcm for 2D correlation matrices or the appropriate new functions for 3D plots.

Usage

# S3 method for cm
ggplot(
  data,
  mapping = NULL,
  ...,
  show.stat = TRUE,
  environment = parent.frame()
)

Value

A ggplot object visualizing the correlation matrix. For 3D arrays, returns NULL.

Arguments

data

A numeric 2D matrix of correlation coefficients. (For 3D arrays, a warning is issued.)

mapping

Optional ggplot2 aesthetic mapping.

...

Additional arguments passed to ggplot.

show.stat

Logical. If TRUE, prints the best \(R^2\) value and corresponding bands.

environment

The environment in which to evaluate the plot. Defaults to parent.frame().

Details

This function creates a ggplot visualization from a 2D correlation matrix. It attempts to extract numeric wavelengths from the column names of the input matrix.

This function extracts numeric wavelengths from the column names of data. If these cannot be determined, sequential indices are used instead.

Examples

Run this code
if (FALSE) {
  library(visa)
  data(NSpec.DF)
  x <- NSpec.DF$N  # nitrogen
   # resampled to 10 nm steps
  S <- NSpec.DF$spectra[, seq(1, ncol(NSpec.DF$spectra), 10)]
  cm2d <- cm.sr(S, x, cm.plot = FALSE)
  p2d <- ggplot.cm(cm2d)
  print(p2d)

}

Run the code above in your browser using DataLab