% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/paintr-server.R
\name{ptr_gg_extra}
\alias{ptr_gg_extra}
\title{Add \code{ggplot2} Layers Programmatically}
\usage{
ptr_gg_extra(state, ...)
}
\arguments{
\item{state}{A \code{ptr_state} from \code{\link[=ptr_init_state]{ptr_init_state()}}.}

\item{...}{\code{ggplot2} layer expressions (e.g.
\code{ptr_gg_extra(state, ggplot2::scale_x_log10(), theme_minimal())}).
Captured unevaluated and stored as quosures, then evaluated in
\code{state$eval_env}. Eval errors propagate and leave the existing
extras untouched (atomic update).}
}
\value{
\code{state}, invisibly.
}
\description{
Evaluate one or more \code{ggplot2} expressions and attach the results as
"extras" on the state. Extras are folded into the plot during the next
runtime cycle when \code{state$runtime()$ok} is \code{TRUE}. Eval failures leave
the existing extras untouched.
}
\examples{
shiny::isolate({
  state <- ptr_init_state(
    "ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()"
  )
  state <- ptr_gg_extra(state, ggplot2::theme_minimal())
  ptr_extract_code(state)
})
}
