ggplot.cm: Create a ggplot Plot from Correlation Coefficients...

View source: R/ggplot.cm.R

ggplot.cmR Documentation

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 class 'cm'
ggplot(
  data,
  mapping = NULL,
  ...,
  show.stat = TRUE,
  environment = parent.frame()
)

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.

Value

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

Examples

## Not run: 
  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)


## End(Not run)


visa documentation built on April 4, 2025, 5:40 a.m.