% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_allviz.R
\name{plot_spec}
\alias{plot_spec}
\alias{spec}
\alias{matspec}
\title{Plot 1D NMR Spectra}
\usage{
plot_spec(
  x,
  ppm = NULL,
  shift = c(0, 10),
  backend = c("plotly", "base", "ggplot2"),
  add = FALSE,
  ...
)

spec(...)

matspec(...)
}
\arguments{
\item{x}{Numeric vector (single spectrum) or numeric matrix (spectra in rows).}

\item{ppm}{Numeric vector of chemical shift values. Must match \code{ncol(x)}.}

\item{shift}{Numeric vector of length 2. Chemical shift window to display
(e.g., \code{c(0, 10)}).}

\item{backend}{Character. Rendering backend. One of \code{"plotly"}, \code{"base"},
or \code{"ggplot"}. Defaults to \code{"plotly"}.}

\item{add}{Logical. If \code{TRUE} and \code{backend = "base"}, add spectra to an
existing plot.}

\item{...}{Additional arguments passed to the selected backend.}
}
\value{
\itemize{
\item \code{"plotly"}: a \code{plotly} object.
\item \code{"ggplot"}: a \code{ggplot2} object.
\item \code{"base"}: \code{NULL} (invisibly).
}
}
\description{
Plot one or multiple 1D ¹H NMR spectra using different rendering backends.
}
\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 \code{"base"} and
\code{"plotly"} backends are substantially more memory-efficient than \code{"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)
plot_spec(hiit_raw, shift=c(-0.05,0.05), backend='base')
plot_spec(hiit_raw, shift=c(-0.05,0.05), backend='ggplot2')
}
