% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tf-ggplot.R
\name{tf_ggplot}
\alias{tf_ggplot}
\title{Create a tf-aware ggplot}
\usage{
tf_ggplot(data = NULL, mapping = aes(), ..., arg = NULL, interpolate = TRUE)
}
\arguments{
\item{data}{Default dataset to use for plot. If not provided, must be supplied
in each layer added to the plot.}

\item{mapping}{Default list of aesthetic mappings to use for plot. Can include
tf-specific aesthetics like \code{tf}, \code{tf_x}, \code{tf_y}, \code{tf_ymin}, \code{tf_ymax}.}

\item{...}{Other arguments passed to ggplot2 functions.}

\item{arg}{Optional. Evaluation grid for tf objects. A numeric vector of arg
values, or a single integer specifying the desired grid length (resolved to
an equidistant grid over the tf domain). If \code{NULL} (default), uses the
natural grid of the tf objects.}

\item{interpolate}{Logical. Should tf objects be interpolated to the evaluation
grid? Defaults to TRUE.}
}
\value{
A tf_ggplot object that inherits from ggplot
}
\description{
\code{tf_ggplot()} creates a ggplot object that can handle tf (functional data) aesthetics.
It works similarly to \code{ggplot()} but automatically transforms tf objects into
long-format data suitable for standard ggplot2 geoms.
}
\details{
\code{tf_ggplot} supports the following tf-specific aesthetics:
\itemize{
\item \code{tf}: Maps a \code{tf} object to \code{y} aesthetic (shorthand for \code{tf_y})
\item \code{tf_x}: Maps a \code{tf} object to \code{x} aesthetic
\item \code{tf_y}: Maps a \code{tf} object to \code{y} aesthetic
\item \code{tf_ymin}: Maps a tf object to ymin aesthetic (for ribbons)
\item \code{tf_ymax}: Maps a tf object to ymax aesthetic (for ribbons)
}

When tf aesthetics are used, the data is automatically transformed:
\itemize{
\item tf objects are evaluated on a common grid
\item Each function becomes multiple rows (one per evaluation point)
\item Group identifiers are created to maintain function identity
\item Non-tf columns are replicated appropriately
}
}
\examples{
# Basic usage
data <- data.frame(
id = 1:10,
group = sample(c("A", "B"), 10, replace = TRUE)
)
data$f <- tf_rgp(10)

# Method 1: tf aesthetic in constructor
tf_ggplot(data, ggplot2::aes(tf = f, color = group)) + ggplot2::geom_line()

# Method 2: tf aesthetic in geom (equivalent)
tf_ggplot(data) + ggplot2::geom_line(ggplot2::aes(tf = f, color = group))

# Confidence bands
tf_ggplot(data) +
  ggplot2::geom_ribbon(
    ggplot2::aes(tf_ymin = mean(f) - sd(f), tf_ymax = mean(f) + sd(f)),
    alpha = 0.3
  ) +
  ggplot2::geom_line(ggplot2::aes(tf = mean(f)))

}
