Plot one or multiple 1D ¹H NMR spectra using different rendering backends.
Arguments
- x
Numeric vector (single spectrum) or numeric matrix (spectra in rows).
- ppm
Numeric vector of chemical shift values. Must match
ncol(x).- shift
Numeric vector of length 2. Chemical shift window to display (e.g.,
c(0, 10)).- backend
Character. Rendering backend. One of
"plotly","base", or"ggplot". Defaults to"plotly".- add
Logical. If
TRUEandbackend = "base", add spectra to an existing plot.- ...
Additional arguments passed to the selected backend.
Details
The function accepts both single spectra and matrices of spectra. Input is internally normalized to matrix form, subset to the selected ppm region, and then rendered using the chosen backend.
For large NMR datasets (e.g., >500 spectra × >10k ppm), the "base" and
"plotly" backends are substantially more memory-efficient than "ggplot",
which requires reshaping to long format.
Chemical shift axes are automatically displayed in decreasing order (NMR convention).
Examples
data(hiit_raw)
plot_spec(hiit_raw)