% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot-data.R
\name{write_plot_data}
\alias{write_plot_data}
\title{Write the exact plot data to CSV}
\usage{
write_plot_data(plot, file, layer = NULL)
}
\arguments{
\item{plot}{A \link{GgnextPlot}.}

\item{file}{Output path. With multiple layers and no \code{layer} given, the
layer index is inserted before the extension
(\code{fig.csv} -> \verb{fig-1.csv}, \verb{fig-2.csv}).}

\item{layer}{Optional layer index (see \code{\link[=plot_data]{plot_data()}}).}
}
\value{
The file path(s) written, invisibly.
}
\description{
Convenience wrapper around \code{\link[=plot_data]{plot_data()}} and \code{\link[utils:write.csv]{utils::write.csv()}} for
publishing the numbers behind a figure next to the figure itself.
}
\examples{
p <- ggnext(cars, aes(speed, dist)) + geom_point()
out <- file.path(tempdir(), "cars.csv")
write_plot_data(p, out)
}
