% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/layer.R
\name{layer_f}
\alias{layer_f}
\title{Create a new layering function.}
\usage{
layer_f(vis, fun)
}
\arguments{
\item{vis}{The ggvis visualisation to modify.}

\item{fun}{A function that takes a single argument, the current
visualisation as input, and returns a modified visualisation.}
}
\description{
The layer function is run, and then the state before the code was run
is restored - this allows layers to be effectively isolated from
the rest of the plot.
}
\examples{
mtcars \%>\% ggvis(~mpg) \%>\%
  layer_f(function(v) {
     v \%>\% compute_bin(~mpg) \%>\% layer_points(x = ~x_, y = ~count_)
  }) \%>\%
  layer_points(y = ~wt)
}
\keyword{internal}
